mirror of
https://github.com/git/git.git
synced 2026-06-19 15:39:47 +02:00
149 lines
5.4 KiB
YAML
149 lines
5.4 KiB
YAML
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@v9
|
|
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);
|
|
}
|
|
|
|
regular:
|
|
name: ${{matrix.vector.jobname}} (${{matrix.vector.pool}})
|
|
needs: ci-config
|
|
if: needs.ci-config.outputs.enabled == 'yes'
|
|
concurrency:
|
|
group: ${{ matrix.vector.jobname }}-${{ matrix.vector.pool }}-${{ github.ref }}
|
|
cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
vector:
|
|
- jobname: osx-clang
|
|
cc: clang
|
|
pool: macos-14
|
|
- jobname: osx-reftable
|
|
cc: clang
|
|
pool: macos-14
|
|
- jobname: osx-gcc
|
|
cc: gcc-13
|
|
pool: macos-14
|
|
- jobname: osx-meson
|
|
cc: clang
|
|
pool: macos-14
|
|
env:
|
|
CC: ${{matrix.vector.cc}}
|
|
CC_PACKAGE: ${{matrix.vector.cc_package}}
|
|
jobname: ${{matrix.vector.jobname}}
|
|
CI_JOB_IMAGE: ${{matrix.vector.pool}}
|
|
TEST_OUTPUT_DIRECTORY: ${{github.workspace}}/t
|
|
runs-on: ${{matrix.vector.pool}}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- run: ci/install-dependencies.sh
|
|
- run: ci/run-build-and-tests.sh
|
|
- name: print test failures
|
|
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
|
|
run: ci/print-test-failures.sh
|
|
- name: Upload failed tests' directories
|
|
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: failed-tests-${{matrix.vector.jobname}}
|
|
path: ${{env.FAILED_TEST_ARTIFACTS}}
|