From b0216953015a22b2cec0a1afb88f3cae2f49d8c4 Mon Sep 17 00:00:00 2001 From: Opeyemi Alao <54288773+Eeebru@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:43:03 +0000 Subject: [PATCH] fix all the linting errors from Workflow Linter V2 --- .github/version-lint.sh | 33 ------------------- .github/workflows/test-lint-workflow.yml | 6 ++-- .../workflows/test-release-version-check.yml | 9 +++-- ...test-report-deployment-status-to-slack.yml | 6 ++-- .../test-report-upcoming-release-version.yml | 3 +- .github/workflows/test-version-bump.yml | 6 ++-- .github/workflows/workflow-linter.yml | 29 +++------------- 7 files changed, 25 insertions(+), 67 deletions(-) delete mode 100755 .github/version-lint.sh diff --git a/.github/version-lint.sh b/.github/version-lint.sh deleted file mode 100755 index 38eb6719..00000000 --- a/.github/version-lint.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -MISSING_VERSION_FILES="" -# Changed files input and trim with new line -FILES_TO_CHANGE=$(tr ' ' '\n' <<< "$1") - -# Read each changed filenames from the input -while IFS= read -r line; do - # Grep for lines with 'uses' and not having version tag - VERSION_PATTERN=$(cat "${line}" | grep 'uses: ' | grep -vE '#\s+v[0-9.]+(\s|$)') - - # Check if $VERSION_PATTERN is not empty - if [[ ! -z "$VERSION_PATTERN" ]]; then - # Read each line that does not have version tag - while IFS= read -r each_line; do - # if the line does not contain bitwarden/gh-actions/* or a .github path - if ! grep -qE 'bitwarden/gh-actions/*|.github/' <<< $each_line ; then - echo "${each_line} in file ${line} is missing actions version tag" - # Add that filename to the variable storing files with missing actions version - MISSING_VERSION_FILES+=" ${line} " - fi - done <<< "$VERSION_PATTERN" - fi -done <<< "$FILES_TO_CHANGE" - -# Trim the variable to be a single line -MISSING_FILES=$(echo $MISSING_VERSION_FILES | tr '\n' ' ') -# Check if the variable is not empty -if [ -n "$MISSING_VERSION_FILES" ]; then - EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) - echo "text<> $GITHUB_OUTPUT - echo "text<> $GITHUB_STEP_SUMMARY -fi diff --git a/.github/workflows/test-lint-workflow.yml b/.github/workflows/test-lint-workflow.yml index a9eb9722..f2fcee0f 100644 --- a/.github/workflows/test-lint-workflow.yml +++ b/.github/workflows/test-lint-workflow.yml @@ -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 @@ -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 }} diff --git a/.github/workflows/test-release-version-check.yml b/.github/workflows/test-release-version-check.yml index 2fa2f112..f2146954 100644 --- a/.github/workflows/test-release-version-check.yml +++ b/.github/workflows/test-release-version-check.yml @@ -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: @@ -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 @@ -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: diff --git a/.github/workflows/test-report-deployment-status-to-slack.yml b/.github/workflows/test-report-deployment-status-to-slack.yml index 6c7ce8b2..3d5b531f 100644 --- a/.github/workflows/test-report-deployment-status-to-slack.yml +++ b/.github/workflows/test-report-deployment-status-to-slack.yml @@ -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 @@ -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 diff --git a/.github/workflows/test-report-upcoming-release-version.yml b/.github/workflows/test-report-upcoming-release-version.yml index f9e25014..edd9d87f 100644 --- a/.github/workflows/test-report-upcoming-release-version.yml +++ b/.github/workflows/test-report-upcoming-release-version.yml @@ -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 diff --git a/.github/workflows/test-version-bump.yml b/.github/workflows/test-version-bump.yml index c6e8def5..a0ab8be3 100644 --- a/.github/workflows/test-version-bump.yml +++ b/.github/workflows/test-version-bump.yml @@ -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 diff --git a/.github/workflows/workflow-linter.yml b/.github/workflows/workflow-linter.yml index 6f26632a..5f6fc864 100644 --- a/.github/workflows/workflow-linter.yml +++ b/.github/workflows/workflow-linter.yml @@ -44,33 +44,14 @@ jobs: echo "modified-workflows=$MODIFIED_EXISTING_WORKFLOWS" >> $GITHUB_OUTPUT - name: Set up Python 3.11 - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b with: python-version: "3.11" - - name: Upgrade pip and install bwwl binary - # if: steps.changed-workflows.outputs.count != 0 - run: | - python -m pip install --upgrade pip - python -m pip install --upgrade bitwarden_workflow_linter + - name: Install bwwl binary + if: steps.changed-workflows.outputs.count != 0 + run: python -m pip install --upgrade bitwarden_workflow_linter - name: Lint - # if: steps.changed-workflows.outputs.count != 0 + if: steps.changed-workflows.outputs.count != 0 run: bwwl lint -f .github/workflows - - - name: Get changed files - # if: steps.changed-workflows.outputs.count != 0 - id: changed-files - 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