mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
Add GitHub Actions configuration
This commit is contained in:
parent
9a6f925bcb
commit
35c7afc6a1
11 changed files with 341 additions and 9 deletions
50
.github/actions/download_artifacts/action.yaml
vendored
Normal file
50
.github/actions/download_artifacts/action.yaml
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
name: Download Artifacts
|
||||
description: Download artifacts preserving file permissions
|
||||
inputs:
|
||||
keys:
|
||||
description: The artifact keys
|
||||
required: true
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
shell: python3 {0}
|
||||
run: |
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.abspath('.github/workflows'))
|
||||
|
||||
from configure_logger import configure_logger
|
||||
from github_api_request import json_github_api_request, download_github_api_request
|
||||
|
||||
from logging import getLogger
|
||||
from os import environ
|
||||
from zipfile import ZipFile
|
||||
import tarfile
|
||||
|
||||
logger = getLogger(__name__)
|
||||
configure_logger(logger)
|
||||
|
||||
input_keys = """${{ inputs.keys }}"""
|
||||
logger.debug(f'Input keys: {input_keys}')
|
||||
artifact_keys = filter(None, [x.strip() for x in input_keys.split('\n')])
|
||||
logger.debug(f'Parsed keys: {artifact_keys}')
|
||||
|
||||
api_prefix = 'actions'
|
||||
artifacts_info = json_github_api_request(f'{api_prefix}/runs/{environ["GITHUB_RUN_ID"]}/artifacts')
|
||||
|
||||
for key in artifact_keys:
|
||||
artifact_id = [x['id'] for x in artifacts_info['artifacts'] if x['name'] == key][0]
|
||||
logger.debug(f'Artifact id: {key}: {artifact_id}')
|
||||
zip_file = f'{key}.zip'
|
||||
download_github_api_request(zip_file, f'{api_prefix}/artifacts/{artifact_id}/zip')
|
||||
logger.debug(f'Unzipping: {zip_file}')
|
||||
with ZipFile(zip_file) as archive:
|
||||
archive.extractall()
|
||||
os.remove(zip_file)
|
||||
tar_file = f'{key}.tar'
|
||||
logger.debug(f'Extracting: {tar_file}')
|
||||
with tarfile.open(tar_file, 'r') as tar:
|
||||
tar.extractall()
|
||||
os.remove(tar_file)
|
||||
|
||||
26
.github/actions/job_wrapper/action.yaml
vendored
Normal file
26
.github/actions/job_wrapper/action.yaml
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
name: Job Wrapper
|
||||
description: Setup and cleanup for build jobs
|
||||
inputs:
|
||||
artifacts:
|
||||
description: Required artifacts
|
||||
required: false
|
||||
default: ''
|
||||
command:
|
||||
description: The build command
|
||||
required: true
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Get artifacts
|
||||
uses: ./.github/actions/download_artifacts
|
||||
with:
|
||||
keys: |
|
||||
JUCE-utils
|
||||
${{ inputs.artifacts }}
|
||||
- run: ${{ inputs.command }}
|
||||
shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }}
|
||||
- name: Handle job failure
|
||||
if: failure()
|
||||
run: python3 JUCE-utils/.github/workflows/post_job.py
|
||||
shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }}
|
||||
|
||||
49
.github/actions/upload_artifact/action.yaml
vendored
Normal file
49
.github/actions/upload_artifact/action.yaml
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
name: Upload Artifact
|
||||
description: Upload an artifact preserving file permissions
|
||||
inputs:
|
||||
key:
|
||||
description: The artifact key
|
||||
required: true
|
||||
paths:
|
||||
description: The artifact paths
|
||||
required: true
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Create tarball
|
||||
shell: python3 {0}
|
||||
run: |
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.abspath('.github/workflows'))
|
||||
|
||||
from configure_logger import configure_logger
|
||||
|
||||
from logging import getLogger
|
||||
from os import mkdir
|
||||
import tarfile
|
||||
|
||||
logger = getLogger(__name__)
|
||||
configure_logger(logger)
|
||||
|
||||
input_paths = """${{ inputs.paths }}"""
|
||||
logger.debug(f'Input paths: {input_paths}')
|
||||
paths = filter(None, [x.strip() for x in input_paths.split('\n')])
|
||||
logger.debug(f'Parsed paths: {paths}')
|
||||
mkdir('tmp_artifact_upload')
|
||||
archive_path = 'tmp_artifact_upload/${{ inputs.key }}.tar'
|
||||
logger.debug(f'Creating archive: {archive_path}')
|
||||
with tarfile.open('tmp_artifact_upload/${{ inputs.key }}.tar', 'w') as tar:
|
||||
for path in paths:
|
||||
logger.debug(f'Adding path to archive archive: {path}')
|
||||
tar.add(path)
|
||||
- uses: actions/upload-artifact@v4.6.0
|
||||
with:
|
||||
name: ${{ inputs.key }}
|
||||
path: tmp_artifact_upload
|
||||
- name: Clean up
|
||||
shell: python3 {0}
|
||||
run: |
|
||||
from shutil import rmtree
|
||||
rmtree('tmp_artifact_upload')
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue