diff --git a/.github/workflows/on-pull-request.yml b/.github/workflows/on-pull-request.yml index 94c70b3..13e3308 100644 --- a/.github/workflows/on-pull-request.yml +++ b/.github/workflows/on-pull-request.yml @@ -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 }} @@ -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 \ No newline at end of file diff --git a/.github/workflows/pr-title-check.yml b/.github/workflows/pr-title-check.yml new file mode 100644 index 0000000..1ef1ca1 --- /dev/null +++ b/.github/workflows/pr-title-check.yml @@ -0,0 +1,37 @@ +name: PR Title Check + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - 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 \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..2a6d43c --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,6 @@ +AllCops: + Exclude: + - 'lib/openapi_client/**/*' + - 'lib/models/update_magic_link_auth_method.rb' + - 'lib/models/update_otp_auth_method.rb' + - 'lib/models/update_passkeys_auth_method.rb' \ No newline at end of file