ci: drop Circle CI in favor of Github Actions #1267
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
push: | |
pull_request: | |
schedule: | |
# Every Friday at 21:30 (UTC). | |
- cron: '30 21 * * 4' | |
workflow_dispatch: | |
inputs: | |
jobs: | |
description: 'Run the specified list of job ids' | |
required: false | |
type: string | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
prepare: | |
name: Prepare | |
runs-on: ubuntu-24.04 | |
outputs: | |
lint: ${{ steps.generate.outputs.lint }} | |
emulator: ${{ steps.generate.outputs.emulator }} | |
macos: ${{ steps.generate.outputs.macos }} | |
platform: ${{ steps.generate.outputs.platform }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
clean: false | |
fetch-depth: 1 | |
show-progress: false | |
sparse-checkout: .github/workflows | |
- name: Generate outputs | |
id: generate | |
run: | | |
printf 'inputs.jobs: %s\n' '${{ inputs.jobs }}' | |
printf 'github.ref: %s\n' '${{ github.ref }}' | |
mapfile -t jobs <<<'${{ inputs.jobs }}'; | |
# NOTE: can't use `[[ ${#jobs[@] -eq 0 ]]` because if `inputs.jobs` is empty then | |
# the array will contain one empty element (input to mapfile is a single newline). | |
if [[ -z "${jobs[*]}" ]]; then | |
jobs=( | |
lint | |
emu_clang | |
emu_gcc_debug | |
macos_arm64 | |
android_arm | |
android_arm64 | |
kindlehf | |
kindlepw2 | |
kobo | |
pocketbook | |
) | |
if [[ -n '${{ github.event.schedule }}' ]]; then | |
jobs='.*' | |
elif [[ '${{ github.ref }}' == 'refs/heads/master' ]]; then | |
jobs+=( | |
emu_gcc | |
android_x86_64 | |
macos_x86-64 | |
cervantes | |
kindle | |
kindle-legacy | |
) | |
fi | |
fi | |
jobs_rx="$(yq --output-format=props '"^(" + join("|") + ")$"' <<<"[$(printf '%s,' "${jobs[@]}")]")" | |
printf 'jobs regex: %s\n' "${jobs_rx}" | |
all_jobs="$(yq --output-format=json . .github/workflows/build.jobs)" | |
for variant in lint emulator macos platform; do | |
jobs="$(jq --arg variant "${variant}" --arg enabled "${jobs_rx}" --compact-output ' | |
[.[$variant][] | select(.id | test($enabled)) | | |
.cache=(.cache // .id) | .target=(.target // .id) | |
]' <<<"${all_jobs}")" | |
printf '%s jobs: ' "${variant}"; jq --color-output <<<"${jobs}" | |
[[ "${jobs}" != '[]' ]] || jobs='' | |
printf '%s=%s\n' "${variant}" "${jobs}" >>"${GITHUB_OUTPUT}" | |
done | |
lint: | |
name: Lint | |
needs: prepare | |
if: needs.prepare.outputs.lint | |
runs-on: ubuntu-latest | |
container: | |
image: koreader/kobase:0.3.4-20.04 | |
options: --user root | |
env: | |
BASH_ENV: '/root/.bashrc' | |
CLICOLOR_FORCE: '1' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
clean: false | |
fetch-depth: 1 | |
show-progress: false | |
- name: Fix checkout ownership | |
run: chown 'root:root' . | |
- name: Lint | |
run: .ci/lint_script.sh | |
emulator: | |
name: Emulator | |
needs: [prepare, lint] | |
if: | | |
!cancelled() && | |
needs.prepare.outputs.emulator && | |
contains('skipped success', needs.lint.result) | |
uses: ./.github/workflows/build_matrix.yml | |
with: | |
jobs: ${{ needs.prepare.outputs.emulator }} | |
macos: | |
name: macOS | |
needs: [prepare, emulator] | |
if: | | |
!cancelled() && | |
needs.prepare.outputs.macos && | |
contains('skipped success', needs.emulator.result) | |
uses: ./.github/workflows/build_matrix.yml | |
with: | |
fail-fast: false | |
jobs: ${{ needs.prepare.outputs.macos }} | |
platform: | |
name: Platform | |
needs: [prepare, emulator] | |
if: | | |
!cancelled() && | |
needs.prepare.outputs.platform && | |
contains('skipped success', needs.emulator.result) | |
uses: ./.github/workflows/build_matrix.yml | |
with: | |
fail-fast: false | |
jobs: ${{ needs.prepare.outputs.platform }} | |
# vim: foldmethod=marker foldlevel=0 |