mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-08 23:18:10 -05:00
Refactor workflow files (#8355)
* Refactor workflow files * Fix YAMLlint errors
This commit is contained in:
committed by
GitHub
parent
4d2a899ddd
commit
41a708c1c5
1
.github/ISSUE_TEMPLATE/config.yml
vendored
1
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1 +1,2 @@
|
||||
---
|
||||
blank_issues_enabled: false
|
||||
|
||||
1
.github/workflows/.mdlrc
vendored
1
.github/workflows/.mdlrc
vendored
@@ -1 +0,0 @@
|
||||
style '.mdl_style.rb'
|
||||
56
.github/workflows/Handoff.yml
vendored
Normal file
56
.github/workflows/Handoff.yml
vendored
Normal file
@@ -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
|
||||
69
.github/workflows/Linters.yml
vendored
69
.github/workflows/Linters.yml
vendored
@@ -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"
|
||||
14
.github/workflows/Markdown-lint.yml
vendored
Normal file
14
.github/workflows/Markdown-lint.yml
vendored
Normal file
@@ -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
|
||||
16
.github/workflows/Rubocop.yml
vendored
Normal file
16
.github/workflows/Rubocop.yml
vendored
Normal file
@@ -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"
|
||||
14
.github/workflows/ShellCheck.yml
vendored
Normal file
14
.github/workflows/ShellCheck.yml
vendored
Normal file
@@ -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/*
|
||||
14
.github/workflows/YAMLlint.yml
vendored
Normal file
14
.github/workflows/YAMLlint.yml
vendored
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user