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/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/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 401f84f..2fdf783 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,11 @@ name: test +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: + workflow_dispatch: push: branches: - 'main' @@ -9,25 +14,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: @@ -47,3 +33,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/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..a12b02d --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,47 @@ +name: validate + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +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 dabd51e..9ec2f42 100644 --- a/README.md +++ b/README.md @@ -2,7 +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) -[![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) +[![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 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 94% rename from __tests__/docker/install.test.e2e.ts rename to __tests__/docker/install.test.itg.ts index f6713ca..0164280 100644 --- a/__tests__/docker/install.test.e2e.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) => { 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",