From eb3bc67a4fe0dea0abdb49b751d00393f161b7a1 Mon Sep 17 00:00:00 2001 From: sophiamersmann Date: Fri, 3 May 2024 10:31:41 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9D=20remove=20svg=20tester=20github?= =?UTF-8?q?=20actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/svg-compare-all-views.yml | 81 --------------------- .github/workflows/svg-compare.yml | 80 -------------------- devTools/svgTester/utils.ts | 11 --- 3 files changed, 172 deletions(-) delete mode 100644 .github/workflows/svg-compare-all-views.yml delete mode 100644 .github/workflows/svg-compare.yml diff --git a/.github/workflows/svg-compare-all-views.yml b/.github/workflows/svg-compare-all-views.yml deleted file mode 100644 index a03c6d3eeab..00000000000 --- a/.github/workflows/svg-compare-all-views.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: SVG diff (all views) -on: [push, pull_request] - -jobs: - svgTesterAllViews: - if: ${{ github.ref_name != 'master-1' }} - runs-on: ubuntu-latest - - steps: - - name: Clone repository - uses: actions/checkout@v4 - - - uses: ./.github/actions/setup-node-yarn-deps - - uses: ./.github/actions/build-tsc - - # Set branch names and token to be used for pushing to the owid-grapher-svgs repo. - # If on a feature branch, create a branch in the owid-grapher-svgs repo with the same name plus a suffix - # to differentiate it from the branch created by the svgTester job. - # If on master, create a new branch with the current timestamp (and suffix) that will be later merged into master. - - name: Set branch name and token for OWID runs - if: ${{ github.repository_owner == 'owid' }} - shell: bash - run: | - [[ ${{ github.ref_name }} = 'master' ]] && suffix="__$(date +%s)__all-views" || suffix="__all-views" - echo "ORIGINAL_BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV - echo "PUSH_BRANCH_NAME=${{ github.ref_name }}$suffix" >> $GITHUB_ENV - echo "TOKEN=${{ secrets.GITHUBPAT }}" >> $GITHUB_ENV - - - name: Set branch name and token for runs from a fork - if: ${{ github.repository_owner != 'owid' }} - shell: bash - run: | - [[ ${{ github.ref_name }} = 'master' ]] && suffix="__$(date +%s)__all-views" || suffix="__all-views" - echo "ORIGINAL_BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV - echo "PUSH_BRANCH_NAME=${{ github.repository_owner }}/${{ github.ref_name }}$suffix" >> $GITHUB_ENV - echo "TOKEN=${{ github.token }}" >> $GITHUB_ENV - - # Checkout the owid-grapher-svgs repo into a subfolder. Use a Personal Access Token for checkout so the - # action will have permission to push later on if required. - - name: Clone svg tester repo - uses: actions/checkout@v4 - with: - repository: "owid/owid-grapher-svgs" - path: owid-grapher-svgs - token: ${{ env.TOKEN }} - - # Switch to or create a branch on that repo that matches the branch name we are on in the owid-grapher repo - # but only do this if we are not on master in owid-graphers (in this case we want to commit and push on master - # in owid-grapher-svgs as well) - - name: create owid-grapher-svgs local branch - if: ${{ env.PUSH_BRANCH_NAME != 'master'}} - working-directory: owid-grapher-svgs - run: git branch ${{ env.PUSH_BRANCH_NAME }} && git checkout ${{ env.PUSH_BRANCH_NAME }} - - # Run the verify tool overwriting any svgs. Stdout is piped to compare-result which will be a 0 byte file if everything works or contain failed grapher ids otherwise - - name: Generate SVGs and compare to reference - id: run-verify-graphs - continue-on-error: true - env: - # using "ternary operator" from https://github.com/actions/runner/issues/409#issuecomment-752775072 - RM_ON_ERROR: ${{ env.ORIGINAL_BRANCH_NAME == 'master' && '' || '--rm-on-error' }} - run: node --enable-source-maps itsJustJavascript/devTools/svgTester/verify-graphs.js -i owid-grapher-svgs/configs -o owid-grapher-svgs/all-views/svg -r owid-grapher-svgs/all-views/svg --ids-from-file owid-grapher-svgs/most-viewed-charts.txt --all-views $RM_ON_ERROR > compare-result - - # The action fails if there were any errors. - - name: Fail with error message if we had errors - if: ${{ steps.run-verify-graphs.outputs.num_errors > 0 }} - uses: actions/github-script@v7 - with: - script: | - core.setFailed('Errors were thrown during checking! Please check diffs at https://github.com/owid/owid-grapher-svgs/commits/${{ env.PUSH_BRANCH_NAME }}') - - # We make the action fail if there were any differences and if we are on a branch other than master. On master - # we do not want to fail because the differences on master are intended to be authorative and thus there is no - # reason to mark this action as failed. - - name: Fail with error message if we had differences - if: ${{ steps.run-verify-graphs.outputs.num_differences > 0 }} - continue-on-error: ${{ env.ORIGINAL_BRANCH_NAME == 'master' }} - uses: actions/github-script@v7 - with: - script: | - core.setFailed('SVGs were different from reference! Please check diffs at https://github.com/owid/owid-grapher-svgs/commits/${{ env.PUSH_BRANCH_NAME }}') diff --git a/.github/workflows/svg-compare.yml b/.github/workflows/svg-compare.yml deleted file mode 100644 index 6069434e6ce..00000000000 --- a/.github/workflows/svg-compare.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: SVG diff -on: [push, pull_request] - -jobs: - svgTester: - if: ${{ github.ref_name != 'master-1' }} - runs-on: ubuntu-latest - - steps: - - name: Clone repository - uses: actions/checkout@v4 - - - uses: ./.github/actions/setup-node-yarn-deps - - uses: ./.github/actions/build-tsc - - # Set branch names and token to be used for pushing to the owid-grapher-svgs repo. - # If on a feature branch, create a new branch in the owid-grapher-svgs repo with the same name. - # If on master, create a new branch with the current timestamp that will be later merged into master. - - name: Set branch name and token for OWID runs - if: ${{ github.repository_owner == 'owid' }} - shell: bash - run: | - [[ ${{ github.ref_name }} = 'master' ]] && suffix="__$(date +%s)" || suffix="" - echo "ORIGINAL_BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV - echo "PUSH_BRANCH_NAME=${{ github.ref_name }}$suffix" >> $GITHUB_ENV - echo "TOKEN=${{ secrets.GITHUBPAT }}" >> $GITHUB_ENV - - - name: Set branch name and token for runs from a fork - if: ${{ github.repository_owner != 'owid' }} - shell: bash - run: | - [[ ${{ github.ref_name }} = 'master' ]] && suffix="__$(date +%s)" || suffix="" - echo "ORIGINAL_BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV - echo "PUSH_BRANCH_NAME=${{ github.repository_owner }}/${{ github.ref_name }}$suffix" >> $GITHUB_ENV - echo "TOKEN=${{ github.token }}" >> $GITHUB_ENV - - # Checkout the owid-grapher-svgs repo into a subfolder. Use a Personal Access Token for checkout so the - # action will have permission to push later on if required. - - name: Clone svg tester repo - uses: actions/checkout@v4 - with: - repository: "owid/owid-grapher-svgs" - path: owid-grapher-svgs - token: ${{ env.TOKEN }} - - # Switch to or create a branch on that repo that matches the branch name we are on in the owid-grapher repo - # but only do this if we are not on master in owid-graphers (in this case we want to commit and push on master - # in owid-grapher-svgs as well) - - name: create owid-grapher-svgs local branch - if: ${{ env.PUSH_BRANCH_NAME != 'master'}} - working-directory: owid-grapher-svgs - run: git branch ${{ env.PUSH_BRANCH_NAME }} && git checkout ${{ env.PUSH_BRANCH_NAME }} - - # Run the verify tool overwriting any svgs. Stdout is piped to compare-result which will be a 0 byte file if everything works or contain failed grapher ids otherwise - - name: Generate SVGs and compare to reference - id: run-verify-graphs - continue-on-error: true - env: - # using "ternary operator" from https://github.com/actions/runner/issues/409#issuecomment-752775072 - RM_ON_ERROR: ${{ env.ORIGINAL_BRANCH_NAME == 'master' && '' || '--rm-on-error' }} - run: node --enable-source-maps itsJustJavascript/devTools/svgTester/verify-graphs.js -i owid-grapher-svgs/configs -o owid-grapher-svgs/svg -r owid-grapher-svgs/svg $RM_ON_ERROR > compare-result - - # The action fails if there were any errors. - - name: Fail with error message if we had errors - if: ${{ steps.run-verify-graphs.outputs.num_errors > 0 }} - uses: actions/github-script@v7 - with: - script: | - core.setFailed('Errors were thrown during checking! Please check diffs at https://github.com/owid/owid-grapher-svgs/commits/${{ env.PUSH_BRANCH_NAME }}') - - # We make the action fail if there were any differences and if we are on a branch other than master. On master - # we do not want to fail because the differences on master are intended to be authorative and thus there is no - # reason to mark this action as failed. - - name: Fail with error message if we had differences - if: ${{ steps.run-verify-graphs.outputs.num_differences > 0 }} - continue-on-error: ${{ env.ORIGINAL_BRANCH_NAME == 'master' }} - uses: actions/github-script@v7 - with: - script: | - core.setFailed('SVGs were different from reference! Please check diffs at https://github.com/owid/owid-grapher-svgs/commits/${{ env.PUSH_BRANCH_NAME }}') diff --git a/devTools/svgTester/utils.ts b/devTools/svgTester/utils.ts index 83207632ef8..239466c9af7 100644 --- a/devTools/svgTester/utils.ts +++ b/devTools/svgTester/utils.ts @@ -643,15 +643,6 @@ export async function renderAndVerifySvg({ } } -// no-op when not running inside GH Actions -const setGhActionsOutput = (key: string, value: string | number) => { - const outPath = process.env.GITHUB_OUTPUT - if (outPath && fs.existsSync(outPath)) { - // this is not bulletproof and expects both to not contain special characters - fs.appendFileSync(outPath, `${key}=${value}`) - } -} - export function displayVerifyResultsAndGetExitCode( validationResults: VerifyResult[], verbose: boolean @@ -682,7 +673,6 @@ export function displayVerifyResultsAndGetExitCode( for (const result of errorResults) { console.log(result.graphId?.toString(), result.error) // write to stdout one grapher id per file for easy piping to other processes } - setGhActionsOutput("num_errors", errorResults.length) } if (differenceResults.length) { console.warn( @@ -695,7 +685,6 @@ export function displayVerifyResultsAndGetExitCode( for (const result of differenceResults) { console.log("", result.difference.chartId) // write to stdout one grapher id per file for easy piping to other processes } - setGhActionsOutput("num_differences", differenceResults.length) } returnCode = errorResults.length + differenceResults.length }