From 668b27606c2fedcd05a71c7ec0dc4e06a30ec349 Mon Sep 17 00:00:00 2001 From: Dan Grebb Date: Sat, 25 Nov 2023 02:29:35 -0500 Subject: [PATCH] feat(github): adds docker sanity test workflows --- .github/workflows/_test-build-publish.yml | 34 ++++++++++ ...test.yml => backstop-integration-test.yml} | 2 +- ...nity-test.yml => backstop-sanity-test.yml} | 8 ++- ...smoke-test.yml => backstop-smoke-test.yml} | 0 .github/workflows/dispatch.yml | 42 ------------ .../{build-docker.yml => docker-build.yml} | 7 +- .../docker-sanity-test-playwright.yml | 66 +++++++++++++++++++ .../docker-sanity-test-puppeteer.yml | 66 +++++++++++++++++++ .../workflows/{test.yml => test-backstop.yml} | 6 +- .github/workflows/test-docker.yml | 21 ++++++ 10 files changed, 199 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/_test-build-publish.yml rename .github/workflows/{integration-test.yml => backstop-integration-test.yml} (95%) rename .github/workflows/{sanity-test.yml => backstop-sanity-test.yml} (81%) rename .github/workflows/{smoke-test.yml => backstop-smoke-test.yml} (100%) delete mode 100644 .github/workflows/dispatch.yml rename .github/workflows/{build-docker.yml => docker-build.yml} (95%) create mode 100644 .github/workflows/docker-sanity-test-playwright.yml create mode 100644 .github/workflows/docker-sanity-test-puppeteer.yml rename .github/workflows/{test.yml => test-backstop.yml} (62%) create mode 100644 .github/workflows/test-docker.yml diff --git a/.github/workflows/_test-build-publish.yml b/.github/workflows/_test-build-publish.yml new file mode 100644 index 000000000..e27758a7d --- /dev/null +++ b/.github/workflows/_test-build-publish.yml @@ -0,0 +1,34 @@ +name: 🙈 Test, Build, & Publish + +on: + workflow_dispatch: + +permissions: + checks: write + contents: write + pull-requests: write + packages: write + +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + +jobs: + sanity-test: + name: Sanity Test + uses: ./.github/workflows/backstop-sanity-test.yml + + smoke-test: + name: Smoke Test + uses: ./.github/workflows/backstop-smoke-test.yml + + integration-test: + name: Integration Test + uses: ./.github/workflows/backstop-integration-test.yml + + build-docker: + name: Build Docker + uses: ./.github/workflows/docker-build.yml + + test-docker: + name: Test Docker + uses: ./.github/workflows/test-docker.yml diff --git a/.github/workflows/integration-test.yml b/.github/workflows/backstop-integration-test.yml similarity index 95% rename from .github/workflows/integration-test.yml rename to .github/workflows/backstop-integration-test.yml index 622534c5a..5aa47cc54 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/backstop-integration-test.yml @@ -1,4 +1,4 @@ -name: Integration Tests +name: Backstop Integration Tests on: pull_request: diff --git a/.github/workflows/sanity-test.yml b/.github/workflows/backstop-sanity-test.yml similarity index 81% rename from .github/workflows/sanity-test.yml rename to .github/workflows/backstop-sanity-test.yml index d2e3c7db9..321e4a23e 100644 --- a/.github/workflows/sanity-test.yml +++ b/.github/workflows/backstop-sanity-test.yml @@ -1,4 +1,4 @@ -name: Sanity Tests +name: Backstop Sanity Tests on: pull_request: @@ -33,6 +33,10 @@ jobs: - name: ↧ Install run: npm ci - - name: 🧪 Test + - name: 🧸 Test Puppeteer run: | npm run sanity-test + + - name: 🎭 Test Playwright + run: | + npm run sanity-test-playwright diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/backstop-smoke-test.yml similarity index 100% rename from .github/workflows/smoke-test.yml rename to .github/workflows/backstop-smoke-test.yml diff --git a/.github/workflows/dispatch.yml b/.github/workflows/dispatch.yml deleted file mode 100644 index bf254f6ac..000000000 --- a/.github/workflows/dispatch.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Workflow Dispatch - -on: - workflow_dispatch: - -permissions: - checks: write - contents: write - pull-requests: write - packages: write - -env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - -jobs: - sanity-test: - name: Sanity Test - uses: ./.github/workflows/sanity-test.yml - with: - REF: ${{ github.ref }} - BRANCH_NAME: $BRANCH_NAME - - smoke-test: - name: Smoke Test - uses: ./.github/workflows/smoke-test.yml - with: - # REF: ${{ github.ref }} - BRANCH_NAME: $BRANCH_NAME - - integration-test: - name: Integration Test - uses: ./.github/workflows/integration-test.yml - with: - REF: ${{ github.ref }} - BRANCH_NAME: $BRANCH_NAME - - build-docker: - name: Build Docker - uses: ./.github/workflows/build-docker.yml - with: - REF: ${{ github.ref }} - BRANCH_NAME: $BRANCH_NAME diff --git a/.github/workflows/build-docker.yml b/.github/workflows/docker-build.yml similarity index 95% rename from .github/workflows/build-docker.yml rename to .github/workflows/docker-build.yml index 152d47078..bca1a6dcf 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/docker-build.yml @@ -1,4 +1,4 @@ -name: Build Docker +name: Docker Build on: pull_request: @@ -15,16 +15,13 @@ env: permissions: contents: write pull-requests: write + packages: write jobs: build-and-push-image: name: 🐳 runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - name: Checkout diff --git a/.github/workflows/docker-sanity-test-playwright.yml b/.github/workflows/docker-sanity-test-playwright.yml new file mode 100644 index 000000000..b677bc443 --- /dev/null +++ b/.github/workflows/docker-sanity-test-playwright.yml @@ -0,0 +1,66 @@ +name: Docker Test - Playwright + +on: + pull_request: + branches: [master, develop] + workflow_dispatch: + workflow_call: + +env: + BRANCH_NAME: ${{ github.event.pull_request.head_ref || github.event.pull_request.head.ref_name || github.head_ref || github.ref_name }} + NODE_VERSION: 20 + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +permissions: + contents: write + pull-requests: write + +jobs: + sanity-test-docker: + name: 🐳 BackstopJS Docker Puppeteer + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref || github.ref }} + + - name: Set Name and Tag Vars + env: + name: "${{ env.BRANCH_NAME }}" + run: | + echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >>${GITHUB_ENV} + echo "TAG=${name/\//-}" >> $GITHUB_ENV + echo "PV=$(cat package.json | jq -r '.version')" >> $GITHUB_ENV + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: ⬢ Setup Node & Cache + uses: actions/setup-node@v3 + with: + cache: "npm" + cache-dependency-path: package-lock.json + + - name: ↧ Install + run: npm ci + + - name: Pull Image + run: | + docker pull $REGISTRY/$IMAGE_NAME_LC:$TAG + + - name: 🐳 Test Docker With Puppeteer + run: | + cd test/configs/ && docker run --rm -it --mount type=bind,source=\"$(pwd)\",target=/src $REGISTRY/$IMAGE_NAME_LC:$REF test --config=playwright" diff --git a/.github/workflows/docker-sanity-test-puppeteer.yml b/.github/workflows/docker-sanity-test-puppeteer.yml new file mode 100644 index 000000000..cdc9df1c8 --- /dev/null +++ b/.github/workflows/docker-sanity-test-puppeteer.yml @@ -0,0 +1,66 @@ +name: Docker Tests - Puppeteer + +on: + pull_request: + branches: [master, develop] + workflow_dispatch: + workflow_call: + +env: + BRANCH_NAME: ${{ github.event.pull_request.head_ref || github.event.pull_request.head.ref_name || github.head_ref || github.ref_name }} + NODE_VERSION: 20 + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +permissions: + contents: write + pull-requests: write + +jobs: + sanity-test-docker: + name: 🐳 BackstopJS Docker Puppeteer + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref || github.ref }} + + - name: Set Name and Tag Vars + env: + name: "${{ env.BRANCH_NAME }}" + run: | + echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >>${GITHUB_ENV} + echo "TAG=${name/\//-}" >> $GITHUB_ENV + echo "PV=$(cat package.json | jq -r '.version')" >> $GITHUB_ENV + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: ⬢ Setup Node & Cache + uses: actions/setup-node@v3 + with: + cache: "npm" + cache-dependency-path: package-lock.json + + - name: ↧ Install + run: npm ci + + - name: Pull Image + run: | + docker pull $REGISTRY/$IMAGE_NAME_LC:$TAG + + - name: 🐳 Test Docker With Puppeteer + run: | + cd test/configs/ && docker run --rm -it --mount type=bind,source=\"$(pwd)\",target=/src $REGISTRY/$IMAGE_NAME_LC:$REF test" diff --git a/.github/workflows/test.yml b/.github/workflows/test-backstop.yml similarity index 62% rename from .github/workflows/test.yml rename to .github/workflows/test-backstop.yml index dfda245b2..36cb8ccbb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test-backstop.yml @@ -13,12 +13,12 @@ permissions: jobs: sanity-test: name: Sanity Test - uses: ./.github/workflows/sanity-test.yml + uses: ./.github/workflows/backstop-sanity-test.yml smoke-test: name: Smoke Test - uses: ./.github/workflows/smoke-test.yml + uses: ./.github/workflows/backstop-smoke-test.yml integration-test: name: Integration Test - uses: ./.github/workflows/integration-test.yml + uses: ./.github/workflows/backstop-integration-test.yml diff --git a/.github/workflows/test-docker.yml b/.github/workflows/test-docker.yml new file mode 100644 index 000000000..fe611471f --- /dev/null +++ b/.github/workflows/test-docker.yml @@ -0,0 +1,21 @@ +name: Docker Tests + +on: + pull_request: + branches: [master, develop] + workflow_call: + workflow_dispatch: + +permissions: + checks: write + contents: write + pull-requests: write + +jobs: + sanity-test: + name: Sanity Test Puppeteer + uses: ./.github/workflows/docker-sanity-test-puppeteer.yml + + smoke-test: + name: Sanity Test Playwright + uses: ./.github/workflows/docker-sanity-test-playwright.yml