From 49bde5a54a7bf071f2630305e4786f0e6038bd78 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 25 Mar 2023 22:01:00 +0100 Subject: [PATCH 1/4] chore: rename e2e to itg tests Signed-off-by: CrazyMax --- .github/workflows/e2e.yml | 84 ------------------- .github/workflows/test.yml | 74 ++++++++++++++++ README.md | 1 - .../{bake.test.e2e.ts => bake.test.itg.ts} | 0 ...nstall.test.e2e.ts => install.test.itg.ts} | 0 dev.Dockerfile | 2 +- jest.config.e2e.ts => jest.config.itg.ts | 2 +- package.json | 8 +- 8 files changed, 80 insertions(+), 91 deletions(-) delete mode 100644 .github/workflows/e2e.yml rename __tests__/buildx/{bake.test.e2e.ts => bake.test.itg.ts} (100%) rename __tests__/docker/{install.test.e2e.ts => install.test.itg.ts} (100%) rename jest.config.e2e.ts => jest.config.itg.ts (96%) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml deleted file mode 100644 index 87f483a..0000000 --- a/.github/workflows/e2e.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: e2e - -on: - workflow_dispatch: - push: - branches: - - 'main' - pull_request: - paths-ignore: - - '.github/*-releases.json' - -jobs: - prepare: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.tests.outputs.matrix }} - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 16 - cache: 'yarn' - - - name: Install - run: yarn install - - - name: Create matrix - id: tests - run: | - declare -a tests - for test in $(yarn run test:e2e-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: - runs-on: ${{ matrix.os }} - needs: - - prepare - strategy: - fail-fast: false - matrix: - test: ${{ fromJson(needs.prepare.outputs.matrix) }} - os: - - ubuntu-latest - - macos-latest - - windows-latest - exclude: - - os: macos-latest - test: buildx/bake.test.e2e.ts - - os: windows-latest - test: buildx/bake.test.e2e.ts - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 16 - cache: 'yarn' - - - name: Install - run: yarn install - - - name: Test - run: yarn test-coverage:e2e --runTestsByPath __tests__/${{ matrix.test }} --coverageDirectory=./coverage - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload coverage - uses: codecov/codecov-action@v3 - with: - file: ./coverage/clover.xml - flags: e2e diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 401f84f..01eb4fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,7 @@ name: test on: + workflow_dispatch: push: branches: - 'main' @@ -47,3 +48,76 @@ jobs: with: file: ./coverage/clover.xml flags: unit + + prepare-itg: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.tests.outputs.matrix }} + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + 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 + - macos-latest + - windows-latest + exclude: + - os: macos-latest + test: buildx/bake.test.itg.ts + - os: windows-latest + test: buildx/bake.test.itg.ts + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'yarn' + - + name: Install + run: yarn install + - + name: Test + run: yarn test:itg-coverage --runTestsByPath __tests__/${{ matrix.test }} --coverageDirectory=./coverage + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - + name: Upload coverage + uses: codecov/codecov-action@v3 + with: + file: ./coverage/clover.xml + flags: itg diff --git a/README.md b/README.md index dabd51e..c1d3a58 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![Downloads](https://img.shields.io/npm/dw/@docker/actions-toolkit?logo=npm&style=flat-square)](https://www.npmjs.com/package/@docker/actions-toolkit) [![Build workflow](https://img.shields.io/github/actions/workflow/status/docker/actions-toolkit/build.yml?label=build&logo=github&style=flat-square)](https://github.com/docker/actions-toolkit/actions?workflow=build) [![Test workflow](https://img.shields.io/github/actions/workflow/status/docker/actions-toolkit/test.yml?label=test&logo=github&style=flat-square)](https://github.com/docker/actions-toolkit/actions?workflow=test) -[![E2E workflow](https://img.shields.io/github/actions/workflow/status/docker/actions-toolkit/e2e.yml?label=e2e&logo=github&style=flat-square)](https://github.com/docker/actions-toolkit/actions?workflow=e2e) [![Codecov](https://img.shields.io/codecov/c/github/docker/actions-toolkit?logo=codecov&style=flat-square)](https://codecov.io/gh/docker/actions-toolkit) # Actions Toolkit diff --git a/__tests__/buildx/bake.test.e2e.ts b/__tests__/buildx/bake.test.itg.ts similarity index 100% rename from __tests__/buildx/bake.test.e2e.ts rename to __tests__/buildx/bake.test.itg.ts diff --git a/__tests__/docker/install.test.e2e.ts b/__tests__/docker/install.test.itg.ts similarity index 100% rename from __tests__/docker/install.test.e2e.ts rename to __tests__/docker/install.test.itg.ts diff --git a/dev.Dockerfile b/dev.Dockerfile index 6231f4f..61ed02a 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -79,7 +79,7 @@ RUN --mount=type=bind,target=.,rw \ --mount=type=bind,from=buildx,source=/buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \ --mount=type=bind,from=buildx,source=/buildx,target=/usr/bin/buildx \ --mount=type=secret,id=GITHUB_TOKEN \ - GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) yarn run test-coverage --coverageDirectory=/tmp/coverage + GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) yarn run test:coverage --coverageDirectory=/tmp/coverage FROM scratch AS test-coverage COPY --from=test /tmp/coverage / diff --git a/jest.config.e2e.ts b/jest.config.itg.ts similarity index 96% rename from jest.config.e2e.ts rename to jest.config.itg.ts index d2656db..b09d6e7 100644 --- a/jest.config.e2e.ts +++ b/jest.config.itg.ts @@ -19,7 +19,7 @@ module.exports = { testEnvironment: 'node', moduleFileExtensions: ['js', 'ts'], setupFiles: ['dotenv/config'], - testMatch: ['**/*.test.e2e.ts'], + testMatch: ['**/*.test.itg.ts'], testTimeout: 1800000, // 30 minutes transform: { '^.+\\.ts$': 'ts-jest' diff --git a/package.json b/package.json index e8cb07f..0fedb02 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,10 @@ "prettier": "prettier --check \"./**/*.ts\"", "prettier:fix": "prettier --write \"./**/*.ts\"", "test": "jest", - "test:e2e": "jest -c jest.config.e2e.ts --runInBand --detectOpenHandles", - "test:e2e-list": "jest -c jest.config.e2e.ts --listTests", - "test-coverage": "jest --coverage", - "test-coverage:e2e": "jest --coverage -c jest.config.e2e.ts --runInBand --detectOpenHandles" + "test:coverage": "jest --coverage", + "test:itg": "jest -c jest.config.itg.ts --runInBand --detectOpenHandles", + "test:itg-list": "jest -c jest.config.itg.ts --listTests", + "test:itg-coverage": "jest --coverage -c jest.config.itg.ts --runInBand --detectOpenHandles" }, "repository": { "type": "git", From a89868cdc57f4be28501b4d39dc19374324fd8b8 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 26 Mar 2023 14:26:31 +0200 Subject: [PATCH 2/4] ci: move validate to a dedicated workflow Signed-off-by: CrazyMax --- .github/workflows/test.yml | 19 --------------- .github/workflows/validate.yml | 43 ++++++++++++++++++++++++++++++++++ README.md | 1 + 3 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/validate.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 01eb4fe..803a8b3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,25 +10,6 @@ on: - '.github/*-releases.json' jobs: - validate: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - target: - - lint - - vendor-validate - - license-validate - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Validate - uses: docker/bake-action@v2 - with: - targets: ${{ matrix.target }} - test: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..3adac25 --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,43 @@ +name: validate + +on: + workflow_dispatch: + push: + branches: + - 'main' + pull_request: + paths-ignore: + - '.github/*-releases.json' + +jobs: + prepare: + runs-on: ubuntu-20.04 + outputs: + targets: ${{ steps.targets.outputs.matrix }} + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Matrix + id: targets + run: | + echo "matrix=$(docker buildx bake validate --print | jq -cr '.group.validate.targets')" >> $GITHUB_OUTPUT + + validate: + runs-on: ubuntu-latest + needs: + - prepare + strategy: + fail-fast: false + matrix: + target: ${{ fromJson(needs.prepare.outputs.targets) }} + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Validate + uses: docker/bake-action@v2 + with: + targets: ${{ matrix.target }} diff --git a/README.md b/README.md index c1d3a58..9ec2f42 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Downloads](https://img.shields.io/npm/dw/@docker/actions-toolkit?logo=npm&style=flat-square)](https://www.npmjs.com/package/@docker/actions-toolkit) [![Build workflow](https://img.shields.io/github/actions/workflow/status/docker/actions-toolkit/build.yml?label=build&logo=github&style=flat-square)](https://github.com/docker/actions-toolkit/actions?workflow=build) [![Test workflow](https://img.shields.io/github/actions/workflow/status/docker/actions-toolkit/test.yml?label=test&logo=github&style=flat-square)](https://github.com/docker/actions-toolkit/actions?workflow=test) +[![Validate workflow](https://img.shields.io/github/actions/workflow/status/docker/actions-toolkit/validate.yml?label=validate&logo=github&style=flat-square)](https://github.com/docker/actions-toolkit/actions?workflow=validate) [![Codecov](https://img.shields.io/codecov/c/github/docker/actions-toolkit?logo=codecov&style=flat-square)](https://codecov.io/gh/docker/actions-toolkit) # Actions Toolkit From 70fba4e0780f85a1c748e561f7b2cdb882e91660 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 26 Mar 2023 14:30:33 +0200 Subject: [PATCH 3/4] ci: concurrency check Signed-off-by: CrazyMax --- .github/workflows/build.yml | 4 ++++ .github/workflows/publish.yml | 4 ++++ .github/workflows/test.yml | 4 ++++ .github/workflows/validate.yml | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c11df2..bbb079d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,9 @@ name: build +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: push: branches: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c193c0a..02df559 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,5 +1,9 @@ name: publish +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: push: tags: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 803a8b3..2fdf783 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,9 @@ name: test +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: workflow_dispatch: push: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 3adac25..a12b02d 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -1,5 +1,9 @@ name: validate +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: workflow_dispatch: push: From da9600bbefab27ba680a605be2d9c8c9fba764a1 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 26 Mar 2023 14:47:10 +0200 Subject: [PATCH 4/4] docker: retries for install integration tests Signed-off-by: CrazyMax --- __tests__/docker/install.test.itg.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/__tests__/docker/install.test.itg.ts b/__tests__/docker/install.test.itg.ts index f6713ca..0164280 100644 --- a/__tests__/docker/install.test.itg.ts +++ b/__tests__/docker/install.test.itg.ts @@ -15,7 +15,7 @@ */ import path from 'path'; -import {describe, expect, test} from '@jest/globals'; +import {jest, describe, expect, test} from '@jest/globals'; import {Install} from '../../src/docker/install'; import {Docker} from '../../src/docker/docker'; @@ -24,6 +24,7 @@ import {Docker} from '../../src/docker/docker'; const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-install-jest'); describe('install', () => { + jest.retryTimes(2); // prettier-ignore test.each(['v23.0.0'])( 'install docker %s', async (version) => {