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

feat(ci): Skip of jobs instead of most steps within job #34004

Merged
merged 13 commits into from
May 9, 2022

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Apr 27, 2022

Until now we have used skipping of steps in a job as a way of reducing CI usage when certain jobs should not be triggered depending on the files being touched.

Now that #33455 & #33784 have been merged, we now have collector jobs (backend/frontend jobs) that represent all the other jobs in them.

This change will make a variable number of jobs be skipped depending on the files being touched.

Until now we have used skipping of steps in a job as a way of reducing CI usage when certain jobs should not be triggered depending on the files being touched.

Now that #33455 & #33784 have been merged, we now have collector jobs (backend/frontend jobs) that represent all the other jobs in them.

This change will make a variable number of jobs be skipped depending on the files being touched.
@@ -33,6 +33,7 @@ jobs:
filters: .github/file-filters.yml

frontend:
if: ${{ needs.files-changed.outputs.acceptance == '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.

This is the same as FE or BE [1]
Checked that the variable is exported in files-changed [2]
[1]

acceptance: &acceptance
- *backend
- *frontend

[2]

files-changed:
name: detect what files changed
runs-on: ubuntu-20.04
timeout-minutes: 3
# Map a step output to a job output
outputs:
acceptance: ${{ steps.changes.outputs.acceptance }}

@@ -29,6 +29,7 @@ jobs:
filters: .github/file-filters.yml

api-docs:
if: needs.files-changed.outputs.api_docs == '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.

Checked that api_docs is exported here:

files-changed:
name: detect what files changed
runs-on: ubuntu-20.04
timeout-minutes: 3
# Map a step output to a job output
outputs:
api_docs: ${{ steps.changes.outputs.api_docs }}
backend: ${{ steps.changes.outputs.backend }}
backend_any_type: ${{ steps.changes.outputs.backend_any_type }}
migration_lockfile: ${{ steps.changes.outputs.migration_lockfile }}
plugins: ${{ steps.changes.outputs.plugins }}

# install ts-node for ts build scripts to execute properly without potentially installing
# conflicting deps when running scripts locally
# see: https://github.com/getsentry/sentry/pull/32328/files
run: |
yarn add ts-node && make test-api-docs

backend-test:
if: needs.files-changed.outputs.backend == '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.

backend is exported:

files-changed:
name: detect what files changed
runs-on: ubuntu-20.04
timeout-minutes: 3
# Map a step output to a job output
outputs:
api_docs: ${{ steps.changes.outputs.api_docs }}
backend: ${{ steps.changes.outputs.backend }}
backend_any_type: ${{ steps.changes.outputs.backend_any_type }}
migration_lockfile: ${{ steps.changes.outputs.migration_lockfile }}
plugins: ${{ steps.changes.outputs.plugins }}

@@ -200,12 +194,13 @@ jobs:

# If working tree is dirty, commit and update if we have a token
- name: Apply any pre-commit fixed files
if: steps.token.outcome == 'success' && github.ref != 'refs/heads/master' && needs.files-changed.outputs.backend == 'true' && always()
if: steps.token.outcome == 'success' && github.ref != 'refs/heads/master' && always()
Copy link
Member Author

Choose a reason for hiding this comment

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

Why is always() in that condition? It seems unnecessary without further investigation.

Copy link
Member

Choose a reason for hiding this comment

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

pre-commit will fail (exit nonzero) and the intent of this is to run anyways and push the files back to the PR

we could scrap all of this and use https://pre-commit.ci

uses: getsentry/action-github-commit@main
with:
github-token: ${{ steps.token.outputs.token }}

migration:
if: needs.files-changed.outputs.migration_lockfile == '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.

Exported:

files-changed:
name: detect what files changed
runs-on: ubuntu-20.04
timeout-minutes: 3
# Map a step output to a job output
outputs:
api_docs: ${{ steps.changes.outputs.api_docs }}
backend: ${{ steps.changes.outputs.backend }}
backend_any_type: ${{ steps.changes.outputs.backend_any_type }}
migration_lockfile: ${{ steps.changes.outputs.migration_lockfile }}
plugins: ${{ steps.changes.outputs.plugins }}

@@ -24,7 +24,7 @@ frontend: &frontend
- 'docs-ui/**'
- 'static/**'
- 'tests/js/**'
- '.github/workflows/frontend.yml'
# - '.github/workflows/frontend.yml'
Copy link
Member Author

Choose a reason for hiding this comment

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

Temp change just for testing

with:
list-files: shell
token: ${{ github.token }}
filters: .github/file-filters.yml
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm removing this since it's not being used. Check that we don't use steps.changes but we use needs.files-changed.

@armenzg
Copy link
Member Author

armenzg commented May 5, 2022

Fake visual snapshot [1]
Screenshots of the jobs skipped [2]

[1]
image

[2]
image
image
image

@armenzg
Copy link
Member Author

armenzg commented May 5, 2022

This shows that this PR skipped all the jobs I wanted and satisfied the GH required checks. I'm going to push one commit to undo my testing changes
image

This reverts commit 8ec947c.
@armenzg
Copy link
Member Author

armenzg commented May 5, 2022

I will not merge this until Monday morning.

Copy link
Member

@asottile-sentry asottile-sentry left a comment

Choose a reason for hiding this comment

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

@@ -112,6 +113,7 @@ jobs:
type: frontend

webpack:
if: ${{ needs.files-changed.outputs.acceptance == 'true' }}
Copy link
Member

Choose a reason for hiding this comment

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

some of these use if ${{ ... }} and others just use if: ... -- the brackets aren't needed I think

steps:
- name: Sentaur attack
run: |
echo "This check pretends to be the Visual Snapshot to satisfy Github required checks"
Copy link
Member

Choose a reason for hiding this comment

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

clever, lol

Copy link
Member

@asottile-sentry asottile-sentry left a comment

Choose a reason for hiding this comment

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

@armenzg armenzg changed the title feat(ci): Support skipping of jobs (#33541) feat(ci): Skip of jobs instead of most steps within job May 6, 2022
@armenzg armenzg enabled auto-merge (squash) May 9, 2022 14:28
@armenzg armenzg disabled auto-merge May 9, 2022 14:49
@armenzg armenzg merged commit 21cf43f into master May 9, 2022
@armenzg armenzg deleted the armenzg/ci/skipping-of-jobs branch May 9, 2022 14:50
armenzg added a commit that referenced this pull request May 11, 2022
…FE changes

This is a fallout from #34004.

This got noticed in [this run](https://github.com/getsentry/sentry/runs/6379373504?check_suite_focus=true) were an FE check failed yet the collector job got skipped instead.
armenzg added a commit that referenced this pull request May 11, 2022
…FE changes (#34486)

This is a fallout from #34004.

This got noticed in [this run](https://github.com/getsentry/sentry/runs/6379373504?check_suite_focus=true) were an FE check failed yet the collector job got skipped instead.
@github-actions github-actions bot locked and limited conversation to collaborators May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: CI Continuous Integration pipeline (GitHub Actions)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants