Skip to content

Commit 70a5041

Browse files
authored
[BRE-139] - Rollout workflow linter V2 (#341)
1 parent 964ffc2 commit 70a5041

8 files changed

+43
-76
lines changed

.github/version-lint.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Workflow Linter PR trigger
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- .github/workflows/workflow-linter.yml
7+
8+
jobs:
9+
linter:
10+
name: Lint
11+
uses: ./.github/workflows/workflow-linter.yml

.github/workflows/test-lint-workflow.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111

1212
jobs:
1313
test-lint-workflow:
14+
name: Test Lint Workflow
1415
runs-on: ubuntu-24.04
1516
steps:
1617
- name: Checkout Branch
@@ -22,6 +23,7 @@ jobs:
2223
WORKFLOW_LIST=$(ls .github/workflows | xargs -I {} echo -n ".github/workflows/{} ")
2324
echo "workflow-list=$WORKFLOW_LIST" >> $GITHUB_OUTPUT
2425
25-
- uses: ./lint-workflow
26+
- name: Lint Workflow
27+
uses: ./lint-workflow
2628
with:
2729
workflows: ${{ steps.workflow-list.outputs.workflow-list }}

.github/workflows/test-release-version-check.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ on:
1313

1414
jobs:
1515
test-version-check:
16-
runs-on: ubuntu-latest
16+
name: Test Version Check
17+
runs-on: ubuntu-22.04
1718
strategy:
1819
fail-fast: false
1920
matrix:
@@ -60,7 +61,8 @@ jobs:
6061
xamarin-calver-success-status: ${{ steps.set-status.outputs.xamarin-calver-success }}
6162
xamarin-calver-fail-status: ${{ steps.set-status.outputs.xamarin-calver-fail }}
6263
steps:
63-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
64+
- name: Checkout Branch
65+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6466

6567
- name: Version Check - ${{ matrix.name }}
6668
id: run-version-check
@@ -80,7 +82,8 @@ jobs:
8082
8183
8284
run-version-check-test:
83-
runs-on: ubuntu-latest
85+
name: Run Version Check Test
86+
runs-on: ubuntu-22.04
8487
needs: [test-version-check]
8588
if: always()
8689
steps:

.github/workflows/test-report-deployment-status-to-slack.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ jobs:
1414
name: Test Slack report
1515
runs-on: ubuntu-22.04
1616
steps:
17-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
- name: Checkout
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1819

1920
- name: Start
2021
uses: ./report-deployment-status-to-slack
@@ -68,7 +69,8 @@ jobs:
6869
name: Test Slack report with different DB migration scenerios
6970
runs-on: ubuntu-22.04
7071
steps:
71-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
72+
- name: Checkout
73+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
7274

7375
- name: With DB migration true on main
7476
uses: ./report-deployment-status-to-slack

.github/workflows/test-report-upcoming-release-version.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ jobs:
1010
name: Test report upcoming release version to Slack
1111
runs-on: ubuntu-22.04
1212
steps:
13-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
13+
- name: Checkout
14+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1415

1516
- name: Report upcoming release version to Slack
1617
uses: ./report-upcoming-release-version

.github/workflows/test-version-bump.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ on:
99

1010
jobs:
1111
test-version-bumps:
12-
runs-on: ubuntu-latest
12+
name: Test Version Bump
13+
runs-on: ubuntu-22.04
1314
steps:
14-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
15+
- name: Checkout
16+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1517

1618
- name: Bump JSON Test
1719
id: test_json

.github/workflows/workflow-linter.yml

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,42 +28,21 @@ jobs:
2828
repository: ${{ steps.repo.outputs.repo }}
2929
fetch-depth: 0
3030

31-
- name: Get changed workflows
32-
id: changed-workflows
33-
run: |
34-
MODIFIED_WORKFLOWS=$(git diff --name-only origin/${{ github.base_ref }} | grep -E '.github/workflows/.*.(yml|yaml)' | tr '\n' ' ')
35-
MODIFIED_EXISTING_WORKFLOWS=""
36-
COUNT=0
37-
for workflow in $MODIFIED_WORKFLOWS; do
38-
if [ -f $workflow ]; then
39-
MODIFIED_EXISTING_WORKFLOWS+=" ${workflow}"
40-
COUNT=$((COUNT+1))
41-
fi
42-
done
43-
echo "count=$COUNT" >> $GITHUB_OUTPUT
44-
echo "modified-workflows=$MODIFIED_EXISTING_WORKFLOWS" >> $GITHUB_OUTPUT
45-
46-
- name: Lint
47-
if: steps.changed-workflows.outputs.count != 0
48-
env:
49-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50-
uses: bitwarden/gh-actions/lint-workflow@main
51-
with:
52-
workflows: ${{ steps.changed-workflows.outputs.modified-workflows }}
53-
5431
- name: Get changed files
55-
if: steps.changed-workflows.outputs.count != 0
56-
id: changed-files
32+
id: changed-workflows
5733
uses: tj-actions/changed-files@c3a1bb2c992d77180ae65be6ae6c166cf40f857c # v45.0.3
5834
with:
5935
files: .github/workflows/**
6036

61-
- name: Check for pinned versions
62-
if: steps.changed-files.outputs.any_changed == 'true'
63-
shell: bash
64-
env:
65-
FILE: ${{ steps.changed-files.outputs.all_changed_files }}
66-
run: |
67-
FILES=$(echo "${{ env.FILE }}")
68-
curl -o $PWD/version-lint.sh https://raw.githubusercontent.com/bitwarden/gh-actions/main/.github/version-lint.sh
69-
chmod +x $PWD/version-lint.sh && $PWD/version-lint.sh $FILES
37+
- name: Set up Python 3.11
38+
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
39+
with:
40+
python-version: "3.11"
41+
42+
- name: Install bwwl binary
43+
if: steps.changed-workflows.outputs.all_changed_files_count != 0
44+
run: python -m pip install --upgrade bitwarden_workflow_linter
45+
46+
- name: Lint
47+
if: steps.changed-workflows.outputs.all_changed_files_count != 0
48+
run: bwwl lint -f .github/workflows

0 commit comments

Comments
 (0)