Skip to content

Commit

Permalink
use verify changes for docs to skip tests (hashicorp#21620) (hashicor…
Browse files Browse the repository at this point in the history
…p#22017)

* use verify changes for docs to skip tests

* add verify-changes to the needed jobs

* skip go tests for doc/ui only changes

* fix a job ref

* change names, remove script

* remove ui conditions

* separate flags

* feedback
  • Loading branch information
hghaf099 authored Jul 21, 2023
1 parent 0e025ed commit bf23fe8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 43 deletions.
17 changes: 1 addition & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,7 @@ concurrency:
jobs:
# verify-changes determines if the changes are only for docs (website)
verify-changes:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
outputs:
is_docs_change: ${{ steps.get-changeddir.outputs.is_docs_change }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 # Use fetch depth 0 for comparing changes to base branch
- name: Get changed directories
id: get-changeddir
env:
TYPE: ${{ github.event_name }}
REF_NAME: ${{ github.ref_name }}
BASE: ${{ github.base_ref }}
run: ./.github/scripts/verify_changes.sh ${{ env.TYPE }} ${{ env.REF_NAME }} ${{ env.BASE }}
uses: ./.github/workflows/verify_changes.yml

product-metadata:
# do not run build and test steps for docs changes
Expand Down
43 changes: 16 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,19 @@ jobs:
run: |
./.github/scripts/oss-diff.sh ${{ steps.determine-branch.outputs.BRANCH }} HEAD
verify-changes:
name: Verify doc-ui only PRs
uses: ./.github/workflows/verify_changes.yml

test-go:
name: Run Go tests
needs:
- setup
# Don't run this job for PR branches starting with:
# 'ui/', 'backport/ui/', 'docs/', or 'backport/docs/'
# OR
# the 'docs' label is present
- verify-changes
# Don't run this job for docs/ui only PRs
if: |
!startsWith(github.head_ref, 'ui/') &&
!startsWith(github.head_ref, 'backport/ui/') &&
!startsWith(github.head_ref, 'docs/') &&
!startsWith(github.head_ref, 'backport/docs/') &&
!contains(github.event.pull_request.labels.*.name, 'docs')
needs.verify-changes.outputs.is_docs_change == 'false' &&
needs.verify-changes.outputs.is_ui_change == 'false'
uses: ./.github/workflows/test-go.yml
with:
# The regular Go tests use an extra runner to execute the
Expand All @@ -124,17 +123,12 @@ jobs:
name: Run Go tests with data race detection
needs:
- setup
# Don't run this job for PR branches starting with:
# 'ui/', 'backport/ui/', 'docs/', or 'backport/docs/'
# OR
# the 'docs' label is present
- verify-changes
# Don't run this job for docs/ui only PRs
if: |
github.event.pull_request.draft == false &&
!startsWith(github.head_ref, 'ui/') &&
!startsWith(github.head_ref, 'backport/ui/') &&
!startsWith(github.head_ref, 'docs/') &&
!startsWith(github.head_ref, 'backport/docs/') &&
!contains(github.event.pull_request.labels.*.name, 'docs')
needs.verify-changes.outputs.is_docs_change == 'false' &&
needs.verify-changes.outputs.is_ui_change == 'false'
uses: ./.github/workflows/test-go.yml
with:
total-runners: 16
Expand All @@ -152,20 +146,15 @@ jobs:

test-go-fips:
name: Run Go tests with FIPS configuration
# Only run this job for the enterprise repo if the PR branch doesn't start with:
# 'ui/', 'backport/ui/', 'docs/', or 'backport/docs/'
# OR
# the 'docs' label is not present
# Only run this job for the enterprise repo if the PR is not docs/ui only
if: |
github.event.pull_request.draft == false &&
needs.setup.outputs.enterprise == 1 &&
!startsWith(github.head_ref, 'ui/') &&
!startsWith(github.head_ref, 'backport/ui/') &&
!startsWith(github.head_ref, 'docs/') &&
!startsWith(github.head_ref, 'backport/docs/') &&
!contains(github.event.pull_request.labels.*.name, 'docs')
needs.verify-changes.outputs.is_docs_change == 'false' &&
needs.verify-changes.outputs.is_ui_change == 'false'
needs:
- setup
- verify-changes
uses: ./.github/workflows/test-go.yml
with:
total-runners: 16
Expand Down

0 comments on commit bf23fe8

Please sign in to comment.