From 41a708c1c5a7799732af1aa7cefb2ace1495fe6e Mon Sep 17 00:00:00 2001 From: Maximilian Downey Twiss Date: Wed, 14 Jun 2023 13:42:56 +1000 Subject: [PATCH] Refactor workflow files (#8355) * Refactor workflow files * Fix YAMLlint errors --- .github/ISSUE_TEMPLATE/config.yml | 1 + .github/workflows/.mdlrc | 1 - .github/workflows/Handoff.yml | 56 +++++++++++++++++++++++ .github/workflows/Linters.yml | 69 ----------------------------- .github/workflows/Markdown-lint.yml | 14 ++++++ .github/workflows/Rubocop.yml | 16 +++++++ .github/workflows/ShellCheck.yml | 14 ++++++ .github/workflows/YAMLlint.yml | 14 ++++++ .mdlrc | 1 - .rubocop.yml | 3 +- .travis.yml | 17 ------- .yamllint.yml | 6 +++ tools/packages.yaml | 2 +- 13 files changed, 124 insertions(+), 90 deletions(-) delete mode 100644 .github/workflows/.mdlrc create mode 100644 .github/workflows/Handoff.yml delete mode 100644 .github/workflows/Linters.yml create mode 100644 .github/workflows/Markdown-lint.yml create mode 100644 .github/workflows/Rubocop.yml create mode 100644 .github/workflows/ShellCheck.yml create mode 100644 .github/workflows/YAMLlint.yml delete mode 100644 .mdlrc delete mode 100644 .travis.yml create mode 100644 .yamllint.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 3ba13e0ce..bd9dfe4ef 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1 +1,2 @@ +--- blank_issues_enabled: false diff --git a/.github/workflows/.mdlrc b/.github/workflows/.mdlrc deleted file mode 100644 index 1f82ca2ce..000000000 --- a/.github/workflows/.mdlrc +++ /dev/null @@ -1 +0,0 @@ -style '.mdl_style.rb' diff --git a/.github/workflows/Handoff.yml b/.github/workflows/Handoff.yml new file mode 100644 index 000000000..7fc337cbb --- /dev/null +++ b/.github/workflows/Handoff.yml @@ -0,0 +1,56 @@ +--- +name: Handoff +on: + pull_request: + branches: [master] +jobs: + handoff: + runs-on: ubuntu-latest + outputs: + category: ${{ steps.changed-file-extensions.outputs.category }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v36 + - name: Get extensions of changed files + id: changed-file-extensions + run: | + category= + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + ext="${file##*.}" + case $ext in + md) + category=Markdown;; + rb) + category=Ruby;; + sh) + category=Bash;; + yml|yaml) + category=YAML;; + *) + echo "Unable to check syntax of $file.";; + esac + # In order for files such as bin/crew to be recognised + [[ "$(file -b $file | cut -d' ' -f1)" == "Ruby" ]] && category=Ruby + done + echo "category=$category" >> $GITHUB_OUTPUT + # Github won't let us do this neatly, see https://github.com/orgs/community/discussions/25246 + markdown: + needs: handoff + if: ${{ needs.handoff.outputs.category == 'Markdown' }} + uses: ./.github/workflows/Markdown-lint.yml + ruby: + needs: handoff + if: ${{ needs.handoff.outputs.category == 'Ruby' }} + uses: ./.github/workflows/Rubocop.yml + bash: + needs: handoff + if: ${{ needs.handoff.outputs.category == 'Bash' }} + uses: ./.github/workflows/ShellCheck.yml + yaml: + needs: handoff + if: ${{ needs.handoff.outputs.category == 'YAML' }} + uses: ./.github/workflows/YAMLlint.yml diff --git a/.github/workflows/Linters.yml b/.github/workflows/Linters.yml deleted file mode 100644 index d73289039..000000000 --- a/.github/workflows/Linters.yml +++ /dev/null @@ -1,69 +0,0 @@ ---- -name: Linters -on: - pull_request: - branches: [master] -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Install ruby - uses: ruby/setup-ruby@v1.150.0 - with: - ruby-version: 3.2.2 - - name: Install linters - run: | - gem install mdl yaml-lint - sudo apt install shellcheck -y - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v35 - - name: Syntax check - run: | - ruby= - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - ext="${file##*.}" - if ! [[ "$ext" =~ ^(md|rb|sh|yml|yaml)$ ]]; then - type="$(file -b "$file" | cut -d' ' -f1)" - case $type in - Bourne-Again) - ext="sh" - ;; - HTML) - ext="md" - ;; - Ruby) - ext="rb" - ;; - esac - fi - case $ext in - md) - mdl -c .mdlrc "$file" - ;; - rb) - ruby=true - ruby -wcWlevel=2 "$file" - ;; - sh) - shellcheck "$file" - ;; - yml|yaml) - yaml-lint "$file" - ;; - *) - echo "Unable to check syntax of $file." - ;; - esac - done - echo "ruby=$ruby" >> $GITHUB_ENV - - name: Rubocop - if: env.ruby - uses: satmandu/Octocop@v0.0.3 - with: - github_token: ${{ secrets.github_token }} - reporter: github-pr-check - rubocop_flags: "-c .rubocop.yml" diff --git a/.github/workflows/Markdown-lint.yml b/.github/workflows/Markdown-lint.yml new file mode 100644 index 000000000..0d3a665a3 --- /dev/null +++ b/.github/workflows/Markdown-lint.yml @@ -0,0 +1,14 @@ +--- +name: Markdown-lint +on: workflow_call +jobs: + markdown-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Markdown-lint + uses: bewuethr/mdl-action@v1 + with: + style-file: .mdl_style.rb diff --git a/.github/workflows/Rubocop.yml b/.github/workflows/Rubocop.yml new file mode 100644 index 000000000..d497f003b --- /dev/null +++ b/.github/workflows/Rubocop.yml @@ -0,0 +1,16 @@ +--- +name: Rubocop +on: workflow_call +jobs: + rubocop: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Rubocop + uses: satmandu/Octocop@v0.0.3 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-check + rubocop_flags: "-l -c .rubocop.yml" diff --git a/.github/workflows/ShellCheck.yml b/.github/workflows/ShellCheck.yml new file mode 100644 index 000000000..6568592b5 --- /dev/null +++ b/.github/workflows/ShellCheck.yml @@ -0,0 +1,14 @@ +--- +name: ShellCheck +on: workflow_call +jobs: + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: ShellCheck + uses: ludeeus/action-shellcheck@master + with: + ignore_paths: ./tools/* diff --git a/.github/workflows/YAMLlint.yml b/.github/workflows/YAMLlint.yml new file mode 100644 index 000000000..0bbda5d8a --- /dev/null +++ b/.github/workflows/YAMLlint.yml @@ -0,0 +1,14 @@ +--- +name: YAMLLint +on: workflow_call +jobs: + yamllint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: YAMLLint + uses: ibiqlik/action-yamllint@v3 + with: + config_file: .yamllint.yml diff --git a/.mdlrc b/.mdlrc deleted file mode 100644 index 1f82ca2ce..000000000 --- a/.mdlrc +++ /dev/null @@ -1 +0,0 @@ -style '.mdl_style.rb' diff --git a/.rubocop.yml b/.rubocop.yml index 261c7d60d..b366c8178 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,4 @@ +--- # The behavior of RuboCop can be controlled via the .rubocop.yml # configuration file. It makes it possible to enable/disable # certain cops (checks) and to alter their behavior if they accept @@ -13,7 +14,7 @@ AllCops: NewCops: enable TargetRubyVersion: 3.1 Exclude: - - 'lib/docopt.rb' + - 'lib/docopt.rb' # These cops have been temporarily disabled and should be reenabled asap Security/Eval: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 444c724ff..000000000 --- a/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: bash -services: - - docker - -before_install: - - docker pull brunux/chromeos - -script: - # Workaround sudo prompting for password by editing existing chronos entry - - docker run -it - -v $PWD:/travis - brunux/chromeos - /bin/sh -c " - grep chronos /etc/sudoers > /tmp/sudoers.new; - sed s/chronos/ALL/ /tmp/sudoers.new > /etc/sudoers; - sudo -u chronos bash /travis/install.sh; - " diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 000000000..34c936607 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,6 @@ +--- +extends: default + +rules: + line-length: disable + truthy: disable diff --git a/tools/packages.yaml b/tools/packages.yaml index 73e1729ba..59c9f2302 100644 --- a/tools/packages.yaml +++ b/tools/packages.yaml @@ -1346,7 +1346,7 @@ activity: low --- kind: url name: dmd -url: https://github.com/dlang/dmd/releases +url: https://github.com/dlang/dmd/releases activity: high --- kind: url