summaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2023-02-16 12:59:52 +0000
committerEdward Thomson <ethomson@vercel.com>2023-02-16 14:15:19 +0000
commitf487b8478af3e2eb737443b8d3bbd3dbcbef29b2 (patch)
tree26d84634bf6317948b8f90f69c18110395509ad9 /.github
parent795758d2ada5b4760664050230343920eab528f6 (diff)
downloadlibgit2-f487b8478af3e2eb737443b8d3bbd3dbcbef29b2.tar.gz
actions: simplify execution with composite action
Diffstat (limited to '.github')
-rw-r--r--.github/actions/run-build/action.yml45
-rw-r--r--.github/workflows/main.yml51
2 files changed, 59 insertions, 37 deletions
diff --git a/.github/actions/run-build/action.yml b/.github/actions/run-build/action.yml
new file mode 100644
index 000000000..41145d3b4
--- /dev/null
+++ b/.github/actions/run-build/action.yml
@@ -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
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 0eedab87a..9df073915 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -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()