From a1bb5e1d3a8f51f7da112b8fde5f5e6cbb95ec42 Mon Sep 17 00:00:00 2001 From: Karl Cardenas Date: Tue, 2 Apr 2024 16:48:11 -0700 Subject: [PATCH] ci: fix branch determination logic (#2568) * ci: fix branch determination logic * chore: fix eslint * ci: fix label logic * chore: revert logic that was working * chore: nope - src filtering clash * chore: new changes * ci: verify variables * ci: fix * ci: path variable * ci: final change --- .github/workflows/visual-comparison.yaml | 19 ++++++++++--------- tsconfig.eslint.json | 2 +- visuals/screenshot.api.spec.ts | 4 ++-- visuals/screenshot.docs.spec.ts | 6 +++--- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/visual-comparison.yaml b/.github/workflows/visual-comparison.yaml index b95efa2c3d..6874e28619 100644 --- a/.github/workflows/visual-comparison.yaml +++ b/.github/workflows/visual-comparison.yaml @@ -5,10 +5,6 @@ on: pull_request: types: [opened, reopened, synchronize, labeled] branches-ignore: ["version-*", "release-*"] - paths: - - 'src/**' - - 'package.json' - - 'package-lock.json' env: @@ -18,8 +14,7 @@ env: ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }} ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} ALGOLIA_SEARCH_KEY: ${{ secrets.ALGOLIA_SEARCH_KEY }} - HTML_REPORT_URL_PATH: reports/${{ github.ref_name }}/${{ github.run_id }}/${{ github.run_attempt }} - + HTML_REPORT_URL_PATH: reports/${{ github.head_ref }}/${{ github.run_id }}/${{ github.run_attempt }} concurrency: @@ -33,12 +28,18 @@ jobs: defaults: run: shell: bash - if: ${{ !github.event.pull_request.draft && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' || contains(github.event.pull_request.labels.*.name, 'visual-tests') }} + if: ${{ !github.event.pull_request.draft && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' && contains(github.event.pull_request.labels.*.name, 'visual-tests') }} steps: # If the condition above is not met, aka, the PR is not in draft status, then this step is skipped. # Because this step is part of the critical path, omission of this step will result in remaining CI steps not gettinge executed. # As of 8/8/2022 there is now way to enforce this beahvior in GitHub Actions CI. - - run: exit 0 + - run: | + echo "GITHUB_BASE_REF: ${{ github.base_ref }}" + echo "GITHUB_HEAD_REF: ${{ github.head_ref }}" + echo "GITHUB_REF_NAME: ${{ github.ref_name }}" + echo "HTML_REPORT_URL_PATH ${{ env.HTML_REPORT_URL_PATH }}" + exit 0 + create-assets: @@ -235,7 +236,7 @@ jobs: uses: mshick/add-pr-comment@v2 with: message: | - 📋 Visual Report for PR ${{ github.ref_name }} with CI run ${{ github.run_id }} and attempt ${{ github.run_attempt }} is ready at + 📋 Visual Report for branch ${{ github.head_ref }} with CI run ${{ github.run_id }} and attempt ${{ github.run_attempt }} is ready at https://spectrocloud.github.io/librarium/${{env.HTML_REPORT_URL_PATH}} 💡 You may have to wait for DNS to resolve or the GitHub Pages job to complete. You can view the progress of the GitHub Pages job [here](https://github.com/spectrocloud/librarium/actions/workflows/pages/pages-build-deployment). diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index a4331a306e..80de3b1401 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -4,6 +4,6 @@ "allowJs": true }, "extends": "./tsconfig.json", - "include": ["src/**/*.ts", "src/**/*.tsx", "./.eslintrc.js", "*.d.ts"], + "include": ["src/**/*.ts", "src/**/*.tsx", "./.eslintrc.js", "*.d.ts", "visuals/**/*.ts", "playwright.config.ts"], "exclude": ["**/node_modules", "deprecated"] } diff --git a/visuals/screenshot.api.spec.ts b/visuals/screenshot.api.spec.ts index de697b9c94..da4b198447 100644 --- a/visuals/screenshot.api.spec.ts +++ b/visuals/screenshot.api.spec.ts @@ -1,12 +1,12 @@ import * as fs from "fs"; import { test, expect } from "@playwright/test"; import { extractSitemapPathnames, WaitForDocusaurusHydration } from "./utils"; +import excludeList from "./exclude.json"; const siteUrl = "http://localhost:3000"; const sitemapPath = "build/sitemap.xml"; const stylesheetPath = "visuals/screenshot.css"; const stylesheet = fs.readFileSync(stylesheetPath).toString(); -const excludeList = require("./exclude.json"); test.describe.configure({ mode: "parallel" }); @@ -21,7 +21,7 @@ function isApiDocsPathname(pathname: string, excludeList: string[]): boolean { return false; } -test.beforeAll(async () => { +test.beforeAll(() => { console.log("Excluded pages: ", excludeList); console.log("Total pages: ", extractSitemapPathnames(sitemapPath).length); }); diff --git a/visuals/screenshot.docs.spec.ts b/visuals/screenshot.docs.spec.ts index 9588901edc..9557a31a5b 100644 --- a/visuals/screenshot.docs.spec.ts +++ b/visuals/screenshot.docs.spec.ts @@ -1,12 +1,12 @@ import * as fs from "fs"; import { test, expect } from "@playwright/test"; import { extractSitemapPathnames, WaitForDocusaurusHydration } from "./utils"; -// Constants: +import excludeList from "./exclude.json"; + const siteUrl = "http://localhost:3000"; const sitemapPath = "build/sitemap.xml"; const stylesheetPath = "visuals/screenshot.css"; const stylesheet = fs.readFileSync(stylesheetPath).toString(); -const excludeList = require("./exclude.json"); test.describe.configure({ mode: "parallel" }); @@ -23,7 +23,7 @@ function isVersionedDocsPathname(pathname: string, excludeList: string[]): boole return true; } -test.beforeAll(async () => { +test.beforeAll(() => { console.log("Excluded pages: ", excludeList); console.log("Total pages: ", extractSitemapPathnames(sitemapPath).length); });