Commit f487b847 by Edward Thomson Committed by Edward Thomson

actions: simplify execution with composite action

parent 795758d2
# 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
...@@ -286,43 +286,20 @@ jobs: ...@@ -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 }} . 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 }} working-directory: ${{ env.docker-config-path }}
if: matrix.platform.container.name != '' && env.docker-container-exists != 'true' if: matrix.platform.container.name != '' && env.docker-container-exists != 'true'
- name: Build and test - name: Prepare build
run: | run: mkdir build
export GITTEST_NEGOTIATE_PASSWORD="${{ secrets.GITTEST_NEGOTIATE_PASSWORD }}" - name: Build
export GITTEST_GITHUB_SSH_KEY="${{ secrets.GITTEST_GITHUB_SSH_KEY }}" uses: ./.github/actions/run-build
export GITTEST_GITHUB_SSH_PUBKEY="${{ secrets.GITTEST_GITHUB_SSH_PUBKEY }}" with:
export GITTEST_GITHUB_SSH_PASSPHRASE="${{ secrets.GITTEST_GITHUB_SSH_PASSPHRASE }}" command: cd build && ../source/ci/build.sh
export GITTEST_GITHUB_SSH_REMOTE_HOSTKEY="${{ secrets.GITTEST_GITHUB_SSH_REMOTE_HOSTKEY }}" container: ${{ matrix.platform.container.name }}
container-version: ${{ env.docker-registry-container-sha }}
if [ -n "${{ matrix.platform.container.name }}" ]; then - name: Test
mkdir build uses: .github/workflows/run-build.yml@ethomson/workflow
docker run \ with:
--rm \ command: cd build && ../source/ci/test.sh
--user "$(id -u):$(id -g)" \ container: ${{ matrix.platform.container.name }}
-v "$(pwd)/source:/home/libgit2/source" \ container-version: ${{ env.docker-registry-container-sha }}
-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: Upload test results - name: Upload test results
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
if: success() || failure() if: success() || failure()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment