Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐝 (svg tester) add GitHub action to test all possible chart views #3062

Merged
merged 8 commits into from
Feb 2, 2024

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Jan 4, 2024

  • Adds a GitHub action to test all possible views of a subset of charts
  • The action works exactly like the other action works
    • To review, it's probably easiest to look at the diff between svg-compare.yml and svg-compare-all-views.yml
  • Both actions commit to the same branch in owid-grapher-svgs
    • Having all SVGs for one change on the same branch is convenient since I often pull from the repo to look at the SVG differences locally (if there are many differences, GitHub often fails too to load the page)
    • Accidental content overwrites are impossible because both actions operate in different directories
  • The verify step:

  • I couldn't get act to run actions locally, so this GitHub action is not tested in any way
  • That's why for now the action is configured to not run automatically. It can only be triggered by the click of a button on GitHub.
  • Once it's properly tested, I'd configure it to run on push/pull.

@sophiamersmann
Copy link
Member Author

sophiamersmann commented Jan 4, 2024

@sophiamersmann sophiamersmann changed the title SVG tester: Add GitHub action to test all views 🐝 SVG tester: Add GitHub action to test all views Jan 4, 2024
@sophiamersmann sophiamersmann force-pushed the svg-tester-action-all-views branch from e9ad638 to 993efdd Compare January 4, 2024 12:53
@sophiamersmann sophiamersmann force-pushed the svg-tester-action-all-views branch 2 times, most recently from 8859888 to dd35855 Compare January 5, 2024 15:16
@sophiamersmann sophiamersmann force-pushed the svg-tester-action-all-views branch from dd35855 to f5ee770 Compare January 5, 2024 15:52
@sophiamersmann sophiamersmann force-pushed the svg-tester-action-all-views branch from f5ee770 to 29b4749 Compare January 5, 2024 16:23
@sophiamersmann sophiamersmann marked this pull request as ready for review January 5, 2024 16:38
@sophiamersmann sophiamersmann changed the title 🐝 SVG tester: Add GitHub action to test all views 🐝 (svg tester) add GitHub action to test all possible chart views Jan 8, 2024
@sophiamersmann sophiamersmann force-pushed the svg-tester-action-all-views branch 2 times, most recently from d987a2c to b5e2e6d Compare January 9, 2024 13:34
@sophiamersmann sophiamersmann force-pushed the svg-tester-action-all-views branch from b5e2e6d to ecc2bce Compare January 10, 2024 09:08
# 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 }}
continue-on-error: true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If both actions commit to the same branch in owid-grapher-svgs, then creating a branch should be a no-op if the branch already exists. git branch <b> fails with exit code 1 if <b> exists, that's why I set continue-on-error to true. I wasn't sure whether the next line (the checkout) would run if the previous line failed. To be on the safe side, the branch is checked out in a separate step.

@@ -0,0 +1,88 @@
name: SVG diff (all views)
on: workflow_dispatch
Copy link
Member Author

@sophiamersmann sophiamersmann Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, this action can only be triggered by a click of a button on GitHub. Once it's properly tested (and I'm sure it actually gives useful feedback), I would set this to push/pull.

env:
# using "ternary operator" from https://github.com/actions/runner/issues/409#issuecomment-752775072
RM_ON_ERROR: ${{ env.PUSH_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
Copy link
Member Author

@sophiamersmann sophiamersmann Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only line of code that is meaningfully different compared to the other action.

@sophiamersmann sophiamersmann force-pushed the svg-tester-action-all-views branch from 4fc2c94 to b06d131 Compare January 22, 2024 11:00
Base automatically changed from svg-tester to master January 22, 2024 12:00
Copy link
Contributor

@danyx23 danyx23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Let's merge this and see if there are any issues when running manually but I'm very excited to have this soon for all commits :)

@sophiamersmann sophiamersmann merged commit 735148e into master Feb 2, 2024
18 checks passed
@sophiamersmann sophiamersmann deleted the svg-tester-action-all-views branch February 2, 2024 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants