2023-01-17 19:07:30 +08:00
|
|
|
name: test
|
|
|
|
|
2023-03-26 20:30:33 +08:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2023-01-17 19:07:30 +08:00
|
|
|
on:
|
2023-03-26 05:01:00 +08:00
|
|
|
workflow_dispatch:
|
2023-01-17 19:07:30 +08:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'main'
|
|
|
|
pull_request:
|
2023-01-31 09:35:21 +08:00
|
|
|
paths-ignore:
|
2023-03-03 02:16:57 +08:00
|
|
|
- '.github/*-releases.json'
|
2023-01-17 19:07:30 +08:00
|
|
|
|
2023-11-12 06:59:01 +08:00
|
|
|
env:
|
|
|
|
NODE_VERSION: "20"
|
2024-06-12 02:37:36 +08:00
|
|
|
BUILDX_VERSION: "v0.15.0"
|
2023-11-12 06:59:01 +08:00
|
|
|
|
2023-01-17 19:07:30 +08:00
|
|
|
jobs:
|
2023-01-31 03:30:44 +08:00
|
|
|
test:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2023-09-05 06:40:48 +08:00
|
|
|
uses: actions/checkout@v4
|
2023-01-17 19:07:30 +08:00
|
|
|
-
|
|
|
|
name: Test
|
2024-06-18 06:54:54 +08:00
|
|
|
uses: docker/bake-action@v5
|
2023-01-17 19:07:30 +08:00
|
|
|
with:
|
2023-01-23 08:38:28 +08:00
|
|
|
targets: test-coverage
|
2023-01-24 07:29:03 +08:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2024-02-05 17:07:54 +08:00
|
|
|
-
|
|
|
|
name: Check coverage
|
|
|
|
run: |
|
|
|
|
if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then
|
|
|
|
echo "RUN_CODECOV=true" >> $GITHUB_ENV
|
|
|
|
else
|
|
|
|
echo "RUN_CODECOV=false" >> $GITHUB_ENV
|
|
|
|
fi
|
|
|
|
shell: bash
|
2023-02-04 11:42:47 +08:00
|
|
|
-
|
|
|
|
name: Upload coverage
|
2024-02-05 17:09:00 +08:00
|
|
|
uses: codecov/codecov-action@v4
|
2024-02-05 17:07:54 +08:00
|
|
|
if: env.RUN_CODECOV == 'true'
|
2023-02-04 11:42:47 +08:00
|
|
|
with:
|
|
|
|
file: ./coverage/clover.xml
|
2023-03-01 03:55:32 +08:00
|
|
|
flags: unit
|
2024-02-23 00:01:50 +08:00
|
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
2023-03-26 05:01:00 +08:00
|
|
|
|
|
|
|
prepare-itg:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
matrix: ${{ steps.tests.outputs.matrix }}
|
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2023-09-05 06:40:48 +08:00
|
|
|
uses: actions/checkout@v4
|
2024-04-26 23:43:17 +08:00
|
|
|
-
|
|
|
|
name: Enable corepack
|
|
|
|
run: |
|
|
|
|
corepack enable
|
|
|
|
yarn --version
|
2023-03-26 05:01:00 +08:00
|
|
|
-
|
|
|
|
name: Setup Node
|
2023-10-24 06:15:26 +08:00
|
|
|
uses: actions/setup-node@v4
|
2023-03-26 05:01:00 +08:00
|
|
|
with:
|
2023-11-12 06:59:01 +08:00
|
|
|
node-version: ${{ env.NODE_VERSION }}
|
2023-03-26 05:01:00 +08:00
|
|
|
cache: 'yarn'
|
|
|
|
-
|
|
|
|
name: Install
|
|
|
|
run: yarn install
|
|
|
|
-
|
|
|
|
name: Create matrix
|
|
|
|
id: tests
|
|
|
|
run: |
|
|
|
|
declare -a tests
|
|
|
|
for test in $(yarn run test:itg-list); do
|
|
|
|
tests+=("${test#$(pwd)/__tests__/}")
|
|
|
|
done
|
|
|
|
echo "matrix=$(echo ${tests[@]} | jq -cR 'split(" ")')" >>${GITHUB_OUTPUT}
|
|
|
|
-
|
|
|
|
name: Show matrix
|
|
|
|
run: |
|
|
|
|
echo ${{ steps.tests.outputs.matrix }}
|
|
|
|
|
|
|
|
test-itg:
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
needs:
|
|
|
|
- prepare-itg
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
test: ${{ fromJson(needs.prepare-itg.outputs.matrix) }}
|
|
|
|
os:
|
|
|
|
- ubuntu-latest
|
2024-04-25 16:12:32 +08:00
|
|
|
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
|
|
|
|
- macos-13
|
|
|
|
- macos-12
|
2023-03-26 05:01:00 +08:00
|
|
|
- windows-latest
|
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2023-09-05 06:40:48 +08:00
|
|
|
uses: actions/checkout@v4
|
2024-04-18 22:33:56 +08:00
|
|
|
-
|
|
|
|
name: Expose GitHub Runtime
|
|
|
|
uses: crazy-max/ghaction-github-runtime@v3
|
2024-04-26 23:43:17 +08:00
|
|
|
-
|
|
|
|
# FIXME: Needs to setup node twice on Windows due to a bug with runner
|
|
|
|
name: Setup Node
|
|
|
|
if: startsWith(matrix.os, 'windows')
|
|
|
|
uses: actions/setup-node@v4
|
|
|
|
with:
|
|
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
-
|
|
|
|
name: Enable corepack
|
|
|
|
run: |
|
|
|
|
corepack enable
|
|
|
|
yarn --version
|
2023-03-26 05:01:00 +08:00
|
|
|
-
|
|
|
|
name: Setup Node
|
2023-10-24 06:15:26 +08:00
|
|
|
uses: actions/setup-node@v4
|
2023-03-26 05:01:00 +08:00
|
|
|
with:
|
2023-11-12 06:59:01 +08:00
|
|
|
node-version: ${{ env.NODE_VERSION }}
|
2023-03-26 05:01:00 +08:00
|
|
|
cache: 'yarn'
|
2024-04-12 16:08:14 +08:00
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
|
|
|
if: startsWith(matrix.os, 'ubuntu')
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
with:
|
|
|
|
version: ${{ env.BUILDX_VERSION }}
|
|
|
|
driver: docker
|
2024-04-22 20:00:35 +08:00
|
|
|
-
|
|
|
|
name: Set up container builder
|
|
|
|
if: startsWith(matrix.os, 'ubuntu')
|
|
|
|
id: builder
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
with:
|
|
|
|
version: ${{ env.BUILDX_VERSION }}
|
|
|
|
use: false
|
2023-03-26 05:01:00 +08:00
|
|
|
-
|
|
|
|
name: Install
|
|
|
|
run: yarn install
|
|
|
|
-
|
|
|
|
name: Test
|
2024-02-05 16:18:16 +08:00
|
|
|
run: |
|
|
|
|
yarn test:itg-coverage --runTestsByPath __tests__/${{ matrix.test }} --coverageDirectory=./coverage
|
2023-03-26 05:01:00 +08:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2024-04-22 20:00:35 +08:00
|
|
|
CTN_BUILDER_NAME: ${{ steps.builder.outputs.name }}
|
2024-02-05 17:07:54 +08:00
|
|
|
-
|
|
|
|
name: Check coverage
|
|
|
|
run: |
|
|
|
|
if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then
|
|
|
|
echo "RUN_CODECOV=true" >> $GITHUB_ENV
|
|
|
|
else
|
|
|
|
echo "RUN_CODECOV=false" >> $GITHUB_ENV
|
|
|
|
fi
|
|
|
|
shell: bash
|
2023-03-26 05:01:00 +08:00
|
|
|
-
|
|
|
|
name: Upload coverage
|
2024-02-05 17:09:00 +08:00
|
|
|
uses: codecov/codecov-action@v4
|
2024-02-05 17:07:54 +08:00
|
|
|
if: env.RUN_CODECOV == 'true'
|
2023-03-26 05:01:00 +08:00
|
|
|
with:
|
|
|
|
file: ./coverage/clover.xml
|
|
|
|
flags: itg
|
2024-02-23 00:01:50 +08:00
|
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|