Skip to content

Commit

Permalink
chore(ci): use prebuilds to speed up ci runs
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Jan 24, 2025
1 parent 2c178dd commit 24a96ac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,32 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
if: github.ref == 'refs/heads/master'
with:
fetch-depth: 0

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
if: github.ref == 'refs/heads/master'
with:
node-version: ${{ env.NODE_VERSION }}

- if: runner.os == 'Windows'
- if: ${{ runner.os == 'Windows' && github.ref == 'refs/heads/master'}}
run: echo "ONLY_DOWNLOAD_PACT_FOR_WINDOWS=true" >> $GITHUB_ENV

- if: ${{ matrix.docker == true && matrix.alpine == true }}
- if: ${{ matrix.docker == true && matrix.alpine == true && github.ref == 'refs/heads/master'}}
name: prebuild linux ${{ matrix.arch }} musl
run: docker run -v $PWD:/home --platform linux/${{ matrix.arch }} --rm node:20-alpine bin/sh -c 'apk add bash && cd /home && bash -c "/home/script/ci/prebuild-alpine.sh" && rm -rf ffi node_modules'

- if: ${{ matrix.docker == true && matrix.alpine != true }}
- if: ${{ matrix.docker == true && matrix.alpine != true && github.ref == 'refs/heads/master' }}
name: prebuild linux ${{ matrix.arch }}
run: docker run -v $PWD:/home --platform linux/${{ matrix.arch }} --rm node:20 bin/bash -c 'cd /home && /home/script/ci/prebuild.sh && rm -rf ffi node_modules'

- run: sudo chown -R $(id -u):$(id -g) prebuilds
if: ${{ matrix.docker == true }}
if: ${{ matrix.docker == true && github.ref == 'refs/heads/master' }}

- run: ./script/ci/prebuild.sh
if: ${{ matrix.docker != true }}
if: ${{ matrix.docker != true && github.ref == 'refs/heads/master'}}

- name: Upload prebuild for ${{ runner.os }}-${{ runner.arch }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
Expand Down Expand Up @@ -156,7 +158,12 @@ jobs:
fetch-depth: 0

- name: Download prebuilds
if: github.ref == 'refs/heads/master'
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
- run: FETCH_ASSETS=true REPO=you54f/pact-js-core ./script/ci/check-release-libs.sh --fetch-assets -t
if: github.ref != 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
Expand Down
2 changes: 1 addition & 1 deletion script/ci/check-release-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if [[ "$TAG" == "" ]]; then
else
GH_TAG_OPTION="$TAG"
if [[ "$TAG" == "latest" ]]; then
GH_TAG_OPTION=''
GH_TAG_OPTION=$(gh release list --limit 1 --repo you54f/pact-js-core --json tagName --jq '.[].tagName')
fi

if [[ "${LIST_ASSETS:-}" = true || "${FETCH_ASSETS:-}" = true ]]; then
Expand Down
12 changes: 7 additions & 5 deletions script/ci/unpack-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ set -u
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running
. "$SCRIPT_DIR"/../lib/robust-bash.sh

ls -1
ls -1 artifact*
mkdir -p prebuilds
mv artifact*/*.tar.gz .
ls *.gz |xargs -n1 tar -xzf
if [ ! -d "prebuilds" ]; then
ls -1
ls -1 artifact*
mkdir -p prebuilds
mv artifact*/*.tar.gz .
ls *.gz | xargs -n1 tar -xzf
fi

"$SCRIPT_DIR"/../download-plugins.sh
# Use the determined platform
Expand Down

0 comments on commit 24a96ac

Please sign in to comment.