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

[BRE-139] - Rollout workflow linter V2 #341

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
33 changes: 0 additions & 33 deletions .github/version-lint.sh

This file was deleted.

6 changes: 4 additions & 2 deletions .github/workflows/test-lint-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ on:

jobs:
test-lint-workflow:
runs-on: ubuntu-latest
name: Test Lint Workflow
runs-on: ubuntu-22.04
steps:
- name: Checkout Branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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
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
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
Loading