Skip to content

Commit

Permalink
[BRE-139] - Rollout workflow linter V2 (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeebru authored Jan 3, 2025
1 parent 964ffc2 commit 70a5041
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 76 deletions.
33 changes: 0 additions & 33 deletions .github/version-lint.sh

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/linter_pr_trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Workflow Linter PR trigger

on:
pull_request:
paths:
- .github/workflows/workflow-linter.yml

jobs:
linter:
name: Lint
uses: ./.github/workflows/workflow-linter.yml
4 changes: 3 additions & 1 deletion .github/workflows/test-lint-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:

jobs:
test-lint-workflow:
name: Test Lint Workflow
runs-on: ubuntu-24.04
steps:
- name: Checkout Branch
Expand All @@ -22,6 +23,7 @@ jobs:
WORKFLOW_LIST=$(ls .github/workflows | xargs -I {} echo -n ".github/workflows/{} ")
echo "workflow-list=$WORKFLOW_LIST" >> $GITHUB_OUTPUT
- uses: ./lint-workflow
- name: Lint Workflow
uses: ./lint-workflow
with:
workflows: ${{ steps.workflow-list.outputs.workflow-list }}
9 changes: 6 additions & 3 deletions .github/workflows/test-release-version-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ on:

jobs:
test-version-check:
runs-on: ubuntu-latest
name: Test Version Check
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -60,7 +61,8 @@ jobs:
xamarin-calver-success-status: ${{ steps.set-status.outputs.xamarin-calver-success }}
xamarin-calver-fail-status: ${{ steps.set-status.outputs.xamarin-calver-fail }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Checkout Branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Version Check - ${{ matrix.name }}
id: run-version-check
Expand All @@ -80,7 +82,8 @@ jobs:
run-version-check-test:
runs-on: ubuntu-latest
name: Run Version Check Test
runs-on: ubuntu-22.04
needs: [test-version-check]
if: always()
steps:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/test-report-deployment-status-to-slack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
name: Test Slack report
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Start
uses: ./report-deployment-status-to-slack
Expand Down Expand Up @@ -68,7 +69,8 @@ jobs:
name: Test Slack report with different DB migration scenerios
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: With DB migration true on main
uses: ./report-deployment-status-to-slack
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-report-upcoming-release-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
name: Test report upcoming release version to Slack
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Report upcoming release version to Slack
uses: ./report-upcoming-release-version
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/test-version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ on:

jobs:
test-version-bumps:
runs-on: ubuntu-latest
name: Test Version Bump
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Bump JSON Test
id: test_json
Expand Down
47 changes: 13 additions & 34 deletions .github/workflows/workflow-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,21 @@ jobs:
repository: ${{ steps.repo.outputs.repo }}
fetch-depth: 0

- name: Get changed workflows
id: changed-workflows
run: |
MODIFIED_WORKFLOWS=$(git diff --name-only origin/${{ github.base_ref }} | grep -E '.github/workflows/.*.(yml|yaml)' | tr '\n' ' ')
MODIFIED_EXISTING_WORKFLOWS=""
COUNT=0
for workflow in $MODIFIED_WORKFLOWS; do
if [ -f $workflow ]; then
MODIFIED_EXISTING_WORKFLOWS+=" ${workflow}"
COUNT=$((COUNT+1))
fi
done
echo "count=$COUNT" >> $GITHUB_OUTPUT
echo "modified-workflows=$MODIFIED_EXISTING_WORKFLOWS" >> $GITHUB_OUTPUT
- name: Lint
if: steps.changed-workflows.outputs.count != 0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: bitwarden/gh-actions/lint-workflow@main
with:
workflows: ${{ steps.changed-workflows.outputs.modified-workflows }}

- name: Get changed files
if: steps.changed-workflows.outputs.count != 0
id: changed-files
id: changed-workflows
uses: tj-actions/changed-files@c3a1bb2c992d77180ae65be6ae6c166cf40f857c # v45.0.3
with:
files: .github/workflows/**

- name: Check for pinned versions
if: steps.changed-files.outputs.any_changed == 'true'
shell: bash
env:
FILE: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
FILES=$(echo "${{ env.FILE }}")
curl -o $PWD/version-lint.sh https://raw.githubusercontent.com/bitwarden/gh-actions/main/.github/version-lint.sh
chmod +x $PWD/version-lint.sh && $PWD/version-lint.sh $FILES
- name: Set up Python 3.11
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: "3.11"

- name: Install bwwl binary
if: steps.changed-workflows.outputs.all_changed_files_count != 0
run: python -m pip install --upgrade bitwarden_workflow_linter

- name: Lint
if: steps.changed-workflows.outputs.all_changed_files_count != 0
run: bwwl lint -f .github/workflows

0 comments on commit 70a5041

Please sign in to comment.