rootstrap/rails_api_base

View on GitHub
.github/workflows/update_knapsack_report.yml

Summary

Maintainability
Test Coverage
name: Update Knapsack Report

on:
  workflow_dispatch:
# This workflow should be scheduled at certain intervals
# schedule:
#    - cron: '0 0 1 */3 *'
# The above cron would schedule it every 3 months. Replace with the wanted periodicity.

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 60

    services:
      db:
        image: postgres:15
        env:
          POSTGRES_USER: postgres
          POSTGRES_HOST_AUTH_METHOD: trust
        ports:
          - 5432:5432
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    env:
      RAILS_ENV: test

    steps:
    - uses: actions/checkout@v4
    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        bundler-cache: true
    - name: Setup Database
      run: bundle exec rails db:create db:migrate
    - name: Update Knapsack Report
      run: KNAPSACK_GENERATE_REPORT=true bundle exec rspec
    - name: Commit files
      run: |
        git config --local user.email "action@github.com"
        git config --local user.name "GitHub Action"
        git add knapsack_rspec_report.json
        git commit -m "Update knapsack_rspec_report.json"
    - name: Push changes
      run: git push origin HEAD:update-knapsack-report
    - name: Initialize Pull Request
      uses: rootstrap/create-pull-request@v5
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        branch: update-knapsack-report
        base: main
        title: 'Update Knapsack report'
        maintainer_can_modify: true
        draft: false
        body: >
          This is an automated PR. Knapsack uses the report file to distribute tests across different nodes
          so that they all have similar execution times. It's advisable to update the report periodically,
          especially if many test files have been added, for better distribution.