Skip to content

Commit

Permalink
ci: adds linting and formatting jobs to on pull request workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ctran88 committed Oct 30, 2024
1 parent 33bc8b8 commit 511bdf6
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 16 deletions.
49 changes: 33 additions & 16 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: PR Checks
name: Lint, Format, and Test

on:
workflow_call:
workflow_dispatch:
pull_request:
branches:
- main

env:
API_KEY: ${{ secrets.API_KEY }}
Expand All @@ -13,21 +12,39 @@ env:
TEST_USER_ID: ${{ secrets.TEST_USER_ID }}

jobs:
build:
name: Test and Lint
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'

- name: Run Tests
run: |
bundle install
ruby tests/all.rb
- name: Run Linting
run: |
npm install -g prettier @prettier/plugin-ruby
prettier --check '**/*.rb'
- name: Install Rubocop
run: gem install rubocop
- name: Lint
run: rubocop -l
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
- name: Install Rubocop
run: gem install rubocop
- name: Format
run: rubocop --format github
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
- name: Install dependencies
run: bundle install
- name: Test
run: ruby tests/all.rb
36 changes: 36 additions & 0 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: PR Title Check

on:
pull_request:
types:
- opened
- reopened
- edited

jobs:
lint-pr-title:
name: Lint PR Title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
Please update the pull request title to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/).
Details:
```
${{ steps.lint_pr_title.outputs.error_message }}
```
# Delete a previous comment when the issue has been resolved
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
delete: true

0 comments on commit 511bdf6

Please sign in to comment.