From 85654f6aaf7317646b38bf504f2c62283afe089d Mon Sep 17 00:00:00 2001 From: vmfunc Date: Tue, 15 Oct 2024 02:51:52 +0200 Subject: [PATCH] ci: various improvements to workflow --- .github/workflows/automatic-rebase.yml | 18 +++++++ .github/workflows/check-large-files.yml | 18 +++++++ .github/workflows/dependency-review.yml | 22 ++++++++ .github/workflows/language.yml | 25 +++++++++ .github/workflows/markdown-lint.yml | 18 +++++++ .github/workflows/memes.yml | 36 +++++++++++++ .github/workflows/misspell.yml | 20 +++++++ .github/workflows/reportcard.yml | 16 ++++++ .github/workflows/reviewdog.yml | 71 +++++++++++++++++++++++++ .github/workflows/shellcheck.yml | 18 +++++++ .github/workflows/yaml-lint.yml | 19 +++++++ 11 files changed, 281 insertions(+) create mode 100644 .github/workflows/automatic-rebase.yml create mode 100644 .github/workflows/check-large-files.yml create mode 100644 .github/workflows/dependency-review.yml create mode 100644 .github/workflows/language.yml create mode 100644 .github/workflows/markdown-lint.yml create mode 100644 .github/workflows/memes.yml create mode 100644 .github/workflows/misspell.yml create mode 100644 .github/workflows/reportcard.yml create mode 100644 .github/workflows/reviewdog.yml create mode 100644 .github/workflows/shellcheck.yml create mode 100644 .github/workflows/yaml-lint.yml diff --git a/.github/workflows/automatic-rebase.yml b/.github/workflows/automatic-rebase.yml new file mode 100644 index 0000000..286c271 --- /dev/null +++ b/.github/workflows/automatic-rebase.yml @@ -0,0 +1,18 @@ +name: Automatic Rebase +on: + issue_comment: + types: [created] +jobs: + rebase: + name: Rebase + if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') + runs-on: ubuntu-latest + steps: + - name: Checkout the latest code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Automatic Rebase + uses: cirrus-actions/rebase@1.8 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/check-large-files.yml b/.github/workflows/check-large-files.yml new file mode 100644 index 0000000..f916899 --- /dev/null +++ b/.github/workflows/check-large-files.yml @@ -0,0 +1,18 @@ +name: Check Large Files + +on: + pull_request: + push: + branches: [main] + +jobs: + check-large-files: + name: Check for large files + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Check for large files + run: | + find . -type f -size +5M | while read file; do + echo "::error file=${file}::File ${file} is larger than 5MB" + done diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000..a8e3114 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,22 @@ +name: "Dependency Review" +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: "Checkout Repository" + uses: actions/checkout@v3 + - name: "Dependency Review" + uses: actions/dependency-review-action@v3 + continue-on-error: ${{ github.event_name == 'push' }} + - name: "Check Dependency Review Outcome" + if: github.event_name == 'push' && failure() + run: | + echo "::warning::Dependency review failed. Please check the dependencies for potential issues." diff --git a/.github/workflows/language.yml b/.github/workflows/language.yml new file mode 100644 index 0000000..2a28959 --- /dev/null +++ b/.github/workflows/language.yml @@ -0,0 +1,25 @@ +name: Mind your language +on: + issues: + types: + - opened + - edited + issue_comment: + types: + - created + - edited + pull_request_review_comment: + types: + - created + - edited +jobs: + echo_issue_comment: + runs-on: ubuntu-latest + name: profanity check + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Profanity check step + uses: tailaiw/mind-your-language-action@v1.0.3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/markdown-lint.yml b/.github/workflows/markdown-lint.yml new file mode 100644 index 0000000..fafd87a --- /dev/null +++ b/.github/workflows/markdown-lint.yml @@ -0,0 +1,18 @@ +name: Markdown Lint + +on: + pull_request: + paths: + - "**/*.md" + +jobs: + markdownlint: + name: runner / markdownlint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: markdownlint + uses: reviewdog/action-markdownlint@v0.10.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review diff --git a/.github/workflows/memes.yml b/.github/workflows/memes.yml new file mode 100644 index 0000000..8c6fa98 --- /dev/null +++ b/.github/workflows/memes.yml @@ -0,0 +1,36 @@ +name: Memer Workflow + +on: [pull_request] + +jobs: + greeting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Run Memer Action + id: memer + + uses: Bhupesh-V/memer-action@master + with: + filter: "new" + + - name: Check Outputs + run: | + echo "${{ steps.memer.outputs.meme }}" + echo "${{ steps.memer.outputs.title }}" + echo "${{ steps.memer.outputs.source }}" + + - name: Create comment + uses: peter-evans/create-or-update-comment@v1.3.0 + id: couc + with: + issue-number: ${{ github.event.number }} + body: | + 🎉🎉 Thanks for opening this PR/Issue + Please wait while the maintainer(s) review it + + Meanwhile have a look at this: + + > **${{ steps.memer.outputs.title }}** + ![meme](${{ steps.memer.outputs.meme }}) + ℹī¸ Source [ Powered By đŸ”Ĩ Memer Action ] diff --git a/.github/workflows/misspell.yml b/.github/workflows/misspell.yml new file mode 100644 index 0000000..6f25482 --- /dev/null +++ b/.github/workflows/misspell.yml @@ -0,0 +1,20 @@ +name: Misspell Check + +on: + pull_request: + push: + branches: [main] + +jobs: + misspell: + name: runner / misspell + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: misspell + uses: reviewdog/action-misspell@v1.13.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review + level: warning + locale: "US" diff --git a/.github/workflows/reportcard.yml b/.github/workflows/reportcard.yml new file mode 100644 index 0000000..a097d4d --- /dev/null +++ b/.github/workflows/reportcard.yml @@ -0,0 +1,16 @@ +name: Update Report Card + +on: + push: + branches: [main] + pull_request: + branches: [main] + workflow_call: + +jobs: + update-report-card: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Update Go Report Card + uses: creekorful/goreportcard-action@v1.0 diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml new file mode 100644 index 0000000..b1bb2be --- /dev/null +++ b/.github/workflows/reviewdog.yml @@ -0,0 +1,71 @@ +name: reviewdog +on: [pull_request] +jobs: + # NOTE: golangci-lint doesn't report multiple errors on the same line from + # different linters and just report one of the errors? + + golangci-lint: + name: runner / golangci-lint + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: golangci-lint + uses: reviewdog/action-golangci-lint@v2 + with: + # optionally use a specific version of Go rather than the latest one + go_version: "1.17" + + # Can pass --config flag to change golangci-lint behavior and target + # directory. + golangci_lint_flags: "--config=.github/.golangci.yml ./testdata" + workdir: subdirectory/ + + # Use golint via golangci-lint binary with "warning" level. + golint: + name: runner / golint + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: golint + uses: reviewdog/action-golangci-lint@v2 + with: + golangci_lint_flags: "--disable-all -E golint" + tool_name: golint # Change reporter name. + level: warning # GitHub Status Check won't become failure with this level. + + # You can add more and more supported linters with different config. + errcheck: + name: runner / errcheck + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: errcheck + uses: reviewdog/action-golangci-lint@v2 + with: + golangci_lint_flags: "--disable-all -E errcheck" + tool_name: errcheck + level: info + + # Disable cache of golangci-lint result, go build and go dependencies + with_cache: + name: runner / errcheck + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: golangci-lint + uses: reviewdog/action-golangci-lint@v2 + with: + cache: false diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..efd3bd7 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,18 @@ +name: Shell Check + +on: + pull_request: + paths: + - "**/*.sh" + +jobs: + shellcheck: + name: runner / shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: shellcheck + uses: reviewdog/action-shellcheck@v1.18.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review diff --git a/.github/workflows/yaml-lint.yml b/.github/workflows/yaml-lint.yml new file mode 100644 index 0000000..2c2a31f --- /dev/null +++ b/.github/workflows/yaml-lint.yml @@ -0,0 +1,19 @@ +name: YAML Lint + +on: + pull_request: + paths: + - "**/*.yml" + - "**/*.yaml" + +jobs: + yamllint: + name: runner / yamllint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: yamllint + uses: reviewdog/action-yamllint@v1.8.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review