x #122
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: CI | |
on: [push, pull_request] | |
env: | |
DEVELOPER: 1 | |
# If more than one workflow run is triggered for the very same commit hash | |
# (which happens when multiple branches pointing to the same commit), only | |
# the first one is allowed to run, the second will be kept in the "queued" | |
# state. This allows a successful completion of the first run to be reused | |
# in the second run via the `skip-if-redundant` logic in the `config` job. | |
# | |
# The only caveat is that if a workflow run is triggered for the same commit | |
# hash that another run is already being held, that latter run will be | |
# canceled. For more details about the `concurrency` attribute, see: | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency | |
concurrency: | |
group: ${{ github.sha }} | |
jobs: | |
ci-config: | |
name: config | |
if: vars.CI_BRANCHES == '' || contains(vars.CI_BRANCHES, github.ref_name) | |
runs-on: ubuntu-latest | |
outputs: | |
enabled: ${{ steps.check-ref.outputs.enabled }}${{ steps.skip-if-redundant.outputs.enabled }} | |
skip_concurrent: ${{ steps.check-ref.outputs.skip_concurrent }} | |
steps: | |
- name: try to clone ci-config branch | |
run: | | |
git -c protocol.version=2 clone \ | |
--no-tags \ | |
--single-branch \ | |
-b ci-config \ | |
--depth 1 \ | |
--no-checkout \ | |
--filter=blob:none \ | |
https://github.com/${{ github.repository }} \ | |
config-repo && | |
cd config-repo && | |
git checkout HEAD -- ci/config || : ignore | |
- id: check-ref | |
name: check whether CI is enabled for ref | |
run: | | |
enabled=yes | |
if test -x config-repo/ci/config/allow-ref | |
then | |
echo "::warning::ci/config/allow-ref is deprecated; use CI_BRANCHES instead" | |
if ! config-repo/ci/config/allow-ref '${{ github.ref }}' | |
then | |
enabled=no | |
fi | |
fi | |
skip_concurrent=yes | |
if test -x config-repo/ci/config/skip-concurrent && | |
! config-repo/ci/config/skip-concurrent '${{ github.ref }}' | |
then | |
skip_concurrent=no | |
fi | |
echo "enabled=$enabled" >>$GITHUB_OUTPUT | |
echo "skip_concurrent=$skip_concurrent" >>$GITHUB_OUTPUT | |
- name: skip if the commit or tree was already tested | |
id: skip-if-redundant | |
uses: actions/github-script@v7 | |
if: steps.check-ref.outputs.enabled == 'yes' | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
try { | |
// Figure out workflow ID, commit and tree | |
const { data: run } = await github.rest.actions.getWorkflowRun({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.runId, | |
}); | |
const workflow_id = run.workflow_id; | |
const head_sha = run.head_sha; | |
const tree_id = run.head_commit.tree_id; | |
// See whether there is a successful run for that commit or tree | |
const { data: runs } = await github.rest.actions.listWorkflowRuns({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
per_page: 500, | |
status: 'success', | |
workflow_id, | |
}); | |
for (const run of runs.workflow_runs) { | |
if (head_sha === run.head_sha) { | |
core.warning(`Successful run for the commit ${head_sha}: ${run.html_url}`); | |
core.setOutput('enabled', ' but skip'); | |
break; | |
} | |
if (run.head_commit && tree_id === run.head_commit.tree_id) { | |
core.warning(`Successful run for the tree ${tree_id}: ${run.html_url}`); | |
core.setOutput('enabled', ' but skip'); | |
break; | |
} | |
} | |
} catch (e) { | |
core.warning(e); | |
} | |
windows-meson-build: | |
name: win+Meson build | |
needs: ci-config | |
if: needs.ci-config.outputs.enabled == 'yes' | |
runs-on: windows-latest | |
concurrency: | |
group: windows-meson-build-${{ github.ref }} | |
cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
- name: Set up dependencies | |
shell: pwsh | |
run: pip install meson ninja | |
- name: Setup | |
shell: pwsh | |
run: meson setup build -Dperl=disabled | |
- name: Compile | |
shell: pwsh | |
run: meson compile -C build | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-meson-artifacts | |
path: build | |
windows-meson-test: | |
name: win+Meson test | |
runs-on: windows-latest | |
needs: [ci-config, windows-meson-build] | |
strategy: | |
fail-fast: false | |
matrix: | |
nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
concurrency: | |
group: windows-meson-test-${{ matrix.nr }}-${{ github.ref }} | |
cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
- name: Set up dependencies | |
shell: pwsh | |
run: pip install meson ninja | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: windows-meson-artifacts | |
path: build | |
- name: Setup tmate session | |
shell: bash | |
run: find . | |
- name: Test | |
shell: pwsh | |
run: meson test -C build --list |