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

fix(actions): test conditional needs #1051

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions:

jobs:
linter-pull-request:
name: golangci-lint on a PR
name: golangci-lint on a PR or from a tag
runs-on: ubuntu-22.04
if: github.ref != 'refs/heads/master'
steps:
Expand Down Expand Up @@ -72,7 +72,13 @@ jobs:
releases:
needs: [linter-master, linter-pull-request, tests]
name: GoReleaser Build on All OS but Windows
if: startsWith(github.ref, 'refs/tags/')
# Usage of needs implies that the job will only run if all the jobs it depends on are successful.
# But in our case, either linter-master or linter-pull-request will be skipped.
# So we need to add a condition to check if the linter-master or linter-pull-request job is successful.
# To do so, we use the `if` condition but we also need to add `always()` to make sure the job is run
# related to https://github.com/actions/runner/issues/2205
# since a success() is added by default and skipped jobs make success to fail we need this workaround
Comment on lines +79 to +80
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: you explain what the workaround is, but not what the problem is. Hence it's kind of complicated to understand the problem in the first place. Could you explain it?

Copy link
Member

Choose a reason for hiding this comment

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

praise: thanks, nice explanation!

if: always() && startsWith(github.ref, 'refs/tags/') && (needs.linter-master.result == 'success' || needs.linter-pull-request.result == 'success')
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -94,7 +100,13 @@ jobs:
releases-windows:
needs: [linter-master, linter-pull-request, tests]
name: GoReleaser Build on Windows
if: startsWith(github.ref, 'refs/tags/')
# Usage of needs implies that the job will only run if all the jobs it depends on are successful.
# But in our case, either linter-master or linter-pull-request will be skipped.
# So we need to add a condition to check if the linter-master or linter-pull-request job is successful.
# To do so, we use the `if` condition but we also need to add `always()` to make sure the job is run
# related to https://github.com/actions/runner/issues/2205
# since a success() is added by default and skipped jobs make success to fail we need this workaround
if: always() && startsWith(github.ref, 'refs/tags/') && (needs.linter-master.result == 'success' || needs.linter-pull-request.result == 'success')
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
Expand Down