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

Zalimeni/test ci skips #21779

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .changelog/21779.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
note
```
10 changes: 9 additions & 1 deletion .github/scripts/check_skip_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ set -euo pipefail
# ... `git merge-base origin/$SKIP_CHECK_BRANCH HEAD` would return commit `D`
# `...HEAD` specifies from the common ancestor to the latest commit on the current branch (HEAD)..
skip_check_branch=${SKIP_CHECK_BRANCH:?SKIP_CHECK_BRANCH is required}

git log -n3 --pretty=oneline

echo "skip check branch: $skip_check_branch"
echo "git merge-base origin/$skip_check_branch HEAD~: $(git merge-base origin/$skip_check_branch HEAD~)"
echo "git diff --name-only $(git merge-base origin/$skip_check_branch HEAD~)...HEAD: $(git diff --name-only "$(git merge-base origin/$skip_check_branch HEAD~)"...HEAD)"

files_to_check=$(git diff --name-only "$(git merge-base origin/$skip_check_branch HEAD~)"...HEAD)

# Define the directories to check
Expand All @@ -32,7 +39,8 @@ for file_to_check in "${files_to_check_array[@]}"; do
for dir in "${skipped_directories[@]}"; do
if [[ "$file_to_check" == */check_skip_ci.sh ]] ||
[[ "$file_to_check" == "$dir"* ]] ||
[[ "$file_to_check" == *.md ]]; then
[[ "$file_to_check" == *.md ]] ||
[[ "$file_to_check" == */go-tests.yml ]]; then
file_is_skipped=true
break
fi
Expand Down
13 changes: 1 addition & 12 deletions .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ permissions:
env:
TEST_RESULTS: /tmp/test-results
GOPRIVATE: github.com/hashicorp # Required for enterprise deps
SKIP_CHECK_BRANCH: ${{ github.head_ref || github.ref_name }}

# concurrency
concurrency:
Expand All @@ -31,17 +30,7 @@ concurrency:

jobs:
conditional-skip:
runs-on: ubuntu-latest
name: Get files changed and conditionally skip CI
outputs:
skip-ci: ${{ steps.read-files.outputs.skip-ci }}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
fetch-depth: 0
- name: Get changed files
id: read-files
run: ./.github/scripts/check_skip_ci.sh
uses: ./.github/workflows/reusable-conditional-skip.yml

setup:
needs: [conditional-skip]
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/reusable-conditional-skip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: conditional-skip

on:
workflow_call:
outputs:
skip-ci:
description: "Whether we should skip build and test jobs"
value: ${{ jobs.check-skip.outputs.skip-ci }}

jobs:
check-skip:
runs-on: ubuntu-latest
name: Check whether to skip build and tests
outputs:
skip-ci: ${{ steps.check-changed-files.outputs.skip-ci }}
env:
SKIP_CHECK_BRANCH: ${{ github.head_ref || github.ref_name }}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
fetch-depth: 0
- name: Check changed files
id: check-changed-files
run: ./.github/scripts/check_skip_ci.sh
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Official docker image that includes binaries from releases.hashicorp.com. This
# downloads the release from releases.hashicorp.com and therefore requires that
# the release is published before building the Docker image.
FROM docker.mirror.hashicorp.services/alpine:3.20 as official
FROM docker.mirror.hashicorp.services/alpine:3.19 as official

# This is the release of Consul to pull in.
ARG VERSION
Expand Down
Loading