mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 02:56:17 +00:00
actions: simplify execution with composite action
This commit is contained in:
committed by
Edward Thomson
parent
795758d2ad
commit
f487b8478a
45
.github/actions/run-build/action.yml
vendored
Normal file
45
.github/actions/run-build/action.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# Run a build step in a container or directly on the Actions runner
|
||||
name: Run Build Step
|
||||
description: Run a build step in a container or directly on the Actions runner
|
||||
|
||||
inputs:
|
||||
command:
|
||||
description: Command to run
|
||||
required: true
|
||||
type: string
|
||||
container:
|
||||
description: Optional container to run in
|
||||
type: string
|
||||
container-version:
|
||||
description: Version of the container to run
|
||||
type: string
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- run: |
|
||||
if [ -n "${{ inputs.container }}" ]; then
|
||||
docker run \
|
||||
--rm \
|
||||
--user "$(id -u):$(id -g)" \
|
||||
-v "$(pwd)/source:/home/libgit2/source" \
|
||||
-v "$(pwd)/build:/home/libgit2/build" \
|
||||
-w /home/libgit2 \
|
||||
-e ASAN_SYMBOLIZER_PATH \
|
||||
-e CC \
|
||||
-e CFLAGS \
|
||||
-e CMAKE_GENERATOR \
|
||||
-e CMAKE_OPTIONS \
|
||||
-e GITTEST_NEGOTIATE_PASSWORD \
|
||||
-e GITTEST_FLAKY_STAT \
|
||||
-e PKG_CONFIG_PATH \
|
||||
-e SKIP_NEGOTIATE_TESTS \
|
||||
-e SKIP_SSH_TESTS \
|
||||
-e TSAN_OPTIONS \
|
||||
-e UBSAN_OPTIONS \
|
||||
${{ inputs.container-version }} \
|
||||
/bin/bash -c "${{ inputs.command }}"
|
||||
else
|
||||
${{ inputs.command }}
|
||||
fi
|
||||
shell: bash
|
||||
51
.github/workflows/main.yml
vendored
51
.github/workflows/main.yml
vendored
@@ -286,43 +286,20 @@ jobs:
|
||||
docker build -t ${{ env.docker-registry-container-sha }} --build-arg UID=$(id -u) --build-arg GID=$(id -g) ${BASE_ARG} -f ${{ env.dockerfile }} .
|
||||
working-directory: ${{ env.docker-config-path }}
|
||||
if: matrix.platform.container.name != '' && env.docker-container-exists != 'true'
|
||||
- name: Build and test
|
||||
run: |
|
||||
export GITTEST_NEGOTIATE_PASSWORD="${{ secrets.GITTEST_NEGOTIATE_PASSWORD }}"
|
||||
export GITTEST_GITHUB_SSH_KEY="${{ secrets.GITTEST_GITHUB_SSH_KEY }}"
|
||||
export GITTEST_GITHUB_SSH_PUBKEY="${{ secrets.GITTEST_GITHUB_SSH_PUBKEY }}"
|
||||
export GITTEST_GITHUB_SSH_PASSPHRASE="${{ secrets.GITTEST_GITHUB_SSH_PASSPHRASE }}"
|
||||
export GITTEST_GITHUB_SSH_REMOTE_HOSTKEY="${{ secrets.GITTEST_GITHUB_SSH_REMOTE_HOSTKEY }}"
|
||||
|
||||
if [ -n "${{ matrix.platform.container.name }}" ]; then
|
||||
mkdir build
|
||||
docker run \
|
||||
--rm \
|
||||
--user "$(id -u):$(id -g)" \
|
||||
-v "$(pwd)/source:/home/libgit2/source" \
|
||||
-v "$(pwd)/build:/home/libgit2/build" \
|
||||
-w /home/libgit2 \
|
||||
-e ASAN_SYMBOLIZER_PATH \
|
||||
-e CC \
|
||||
-e CFLAGS \
|
||||
-e CMAKE_GENERATOR \
|
||||
-e CMAKE_OPTIONS \
|
||||
-e GITTEST_NEGOTIATE_PASSWORD \
|
||||
-e GITTEST_FLAKY_STAT \
|
||||
-e PKG_CONFIG_PATH \
|
||||
-e SKIP_NEGOTIATE_TESTS \
|
||||
-e SKIP_SSH_TESTS \
|
||||
-e TSAN_OPTIONS \
|
||||
-e UBSAN_OPTIONS \
|
||||
${{ env.docker-registry-container-sha }} \
|
||||
/bin/bash -c "cd build && ../source/ci/build.sh && ../source/ci/test.sh"
|
||||
else
|
||||
mkdir build
|
||||
cd build
|
||||
../source/ci/build.sh
|
||||
../source/ci/test.sh
|
||||
fi
|
||||
shell: bash
|
||||
- name: Prepare build
|
||||
run: mkdir build
|
||||
- name: Build
|
||||
uses: ./.github/actions/run-build
|
||||
with:
|
||||
command: cd build && ../source/ci/build.sh
|
||||
container: ${{ matrix.platform.container.name }}
|
||||
container-version: ${{ env.docker-registry-container-sha }}
|
||||
- name: Test
|
||||
uses: .github/workflows/run-build.yml@ethomson/workflow
|
||||
with:
|
||||
command: cd build && ../source/ci/test.sh
|
||||
container: ${{ matrix.platform.container.name }}
|
||||
container-version: ${{ env.docker-registry-container-sha }}
|
||||
- name: Upload test results
|
||||
uses: actions/upload-artifact@v3
|
||||
if: success() || failure()
|
||||
|
||||
Reference in New Issue
Block a user