Skip to content

Commit

Permalink
[CI] Fix changelog fragment check (mckinsey#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonymilne authored May 30, 2024
1 parent 540e5ed commit 9e7a179
Showing 4 changed files with 14 additions and 10 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/checks-vizro-ai.yml
Original file line number Diff line number Diff line change
@@ -26,7 +26,9 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
# Use fetch-depth of 2 to enable the changelog fragment check, which only runs in a pull request, not on push.
# See https://stackoverflow.com/questions/74265821/get-modified-files-in-github-actions
fetch-depth: 2

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
@@ -45,9 +47,11 @@ jobs:
- name: Find changed files to see if changelog fragment needed
id: changed-files
if: ${{ github.event_name == 'pull_request' }}
# --no-renames is required so that an empty changelog file added in a release PR always counts as added rather
# than a renamed version of an already-existing empty changelog file.
run: |
echo "changelog_fragment_added=$(git diff --name-only --diff-filter=A -r HEAD^1 HEAD -- 'changelog.d/*.md' | xargs)" >> $GITHUB_OUTPUT
echo "files_outside_docs_changed=$(git diff --name-only -r HEAD^1 HEAD -- ':!docs/*' | xargs)" >> $GITHUB_OUTPUT
echo "changelog_fragment_added=$(git diff --name-only --no-renames --diff-filter=A HEAD^1 HEAD -- 'changelog.d/*.md' | cat)" >> $GITHUB_OUTPUT
echo "files_outside_docs_changed=$(git diff --name-only HEAD^1 HEAD -- ':!docs' | cat)" >> $GITHUB_OUTPUT
- name: Fail if changelog fragment needed and wasn't added
if: ${{ steps.changed-files.outcome != 'skipped' && steps.changed-files.outputs.files_outside_docs_changed && !steps.changed-files.outputs.changelog_fragment_added}}
10 changes: 7 additions & 3 deletions .github/workflows/checks-vizro-core.yml
Original file line number Diff line number Diff line change
@@ -26,7 +26,9 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
# Use fetch-depth of 2 to enable the changelog fragment check, which only runs in a pull request, not on push.
# See https://stackoverflow.com/questions/74265821/get-modified-files-in-github-actions
fetch-depth: 2

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
@@ -48,9 +50,11 @@ jobs:
- name: Find changed files to see if changelog fragment needed
id: changed-files
if: ${{ github.event_name == 'pull_request' }}
# --no-renames is required so that an empty changelog file added in a release PR always counts as added rather
# than a renamed version of an already-existing empty changelog file.
run: |
echo "changelog_fragment_added=$(git diff --name-only --diff-filter=A -r HEAD^1 HEAD -- 'changelog.d/*.md' | xargs)" >> $GITHUB_OUTPUT
echo "files_outside_docs_changed=$(git diff --name-only -r HEAD^1 HEAD -- ':!docs/*' | xargs)" >> $GITHUB_OUTPUT
echo "changelog_fragment_added=$(git diff --name-only --no-renames --diff-filter=A HEAD^1 HEAD -- 'changelog.d/*.md' | cat)" >> $GITHUB_OUTPUT
echo "files_outside_docs_changed=$(git diff --name-only HEAD^1 HEAD -- ':!docs' | cat)" >> $GITHUB_OUTPUT
- name: Fail if changelog fragment needed and wasn't added
if: ${{ steps.changed-files.outcome != 'skipped' && steps.changed-files.outputs.files_outside_docs_changed && !steps.changed-files.outputs.changelog_fragment_added}}
2 changes: 0 additions & 2 deletions .github/workflows/lint-vizro-all.yml
Original file line number Diff line number Diff line change
@@ -22,8 +22,6 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
2 changes: 0 additions & 2 deletions .github/workflows/test-integration-vizro-ai.yml
Original file line number Diff line number Diff line change
@@ -67,8 +67,6 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5

0 comments on commit 9e7a179

Please sign in to comment.