Shared Github Actions
Cleans up after test runs by uploading screenshots and dumping system information to stdout.
Inputs:
artifact-prefix*: A string prefix to name the uploaded log file. Artifact name will be named${artifact-prefix}-logs
Example:
- name: Cleanupuses: RoleModel/actions/test-cleanup@v3with:
artifact-prefix: rspec-systemPosts the runtime of the longest test files. This is important because the most granular parallel_tests goes is at the file level, so when running in parallel, the entire suite can never be quicker than the slowest file.
Inputs:
test-output-path*: Path to the test output file that hold runtimestop-count: Number of slowest tests to show. Default: 10
Example:
- name: Analyze test runtimesuses: RoleModel/actions/test-runtime-analyzer@v3with:
test-output-path: tmp/turbo_rspec_runtime.logUse this action to maintain a staging branch with the changes from all open PRs labeled Staging. This is recommended to be used with a workflow that auto-deploys the staging branch.
If a PR cannot be merged cleanly, the action comments on the PR with conflict details and removes the Staging label.
This action assumes the repository has already been cloned with ref: staging and fetch-depth: 0 set. Commits/pushes made using the default GitHub Actions access key do not trigger other actions, so make sure to generate a personal access token or SSH key so that staging auto-deploys can work.
Inputs:
github-token: GitHub token used to list/update pull requests. Default:${{ github.token }}primary-branch: Branch used as the reset base before staged merges. Default:main
Example:
name: Maintain staging branchon:
pull_request:
types:
- labeled
- unlabeled
- closed
- synchronizejobs:
maintain_staging:
if: (contains(github.event.pull_request.labels[*].name, 'Staging')) || (github.event.action == 'closed' && github.event.pull_request.merged) || (github.event.label.name == 'Staging')runs-on: ubuntu-latesttimeout-minutes: 2steps:
- name: Check out repositoryuses: actions/checkout@v7with:
ref: stagingfetch-depth: 0ssh-key: ${{ secrets.AUTOMATED_COMMITS_KEY }} # IMPORTANT: Use a custom key to allow triggering other workflows
- name: Rebuild staging branchuses: RoleModel/actions/staging-auto-merge@v3This is a combination of multiple composite actions that can be used to run your entire CI flow for a rails app using parallel_tests. Each action allow you to customize the machine, environment variables, and any custom install steps that are needed. It does require you to check out the code yourself, since some install steps might happen after that.
linting-and-non-system-tests:linting_step_required- Whether linting is required
- Optional, default is
false
linting_step_command- Command for linting (e.g., "bundle exec rubocop")
- Optional, default is
''
needs-compiled-assets- Whether to retrieve the Rails asset cache (set to false if your workflow does not depend on the compile-assets workflow)
- Optional, default is
true
system-tests:web-driver- Supported values are 'selenium' and 'playwright'
- Optional, default is
selenium
failure-screenshot-dir- the directory where your test runner saves screenshots on failure
- Optional, default is
tmp/capybara
name: CIon:
push:
branches: [ main, master ]pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}-${{ github.event.ref }}cancel-in-progress: trueenv:
CI: trueRAILS_ENV: testPOSTGRES_USER: postgresPOSTGRES_PASSWORD: passwordSECRET_KEY_BASE: 123# If you are using encrypted credentials, you'll need to extract this into a GitHub secret.# Otherwise, the only thing that matters is that the value is not nil.jobs:
compile-assets:
name: Compile Assetsruns-on: blacksmith-4vcpu-ubuntu-2204timeout-minutes: 5steps:
- name: Checkout Codeuses: actions/checkout@v7
- uses: RoleModel/actions/compile-assets@v3id: check-asset-cachenon-system-test:
name: Linting & Ruby Non-System Testsruns-on: blacksmith-8vcpu-ubuntu-2204timeout-minutes: 5# If you have non-system tests that touch the browser, you may need to uncomment the following line.# needs: compile-assetsservices:
postgres:
image: postgres:17ports:
- "5432:5432"env:
POSTGRES_USER: postgresPOSTGRES_PASSWORD: passwordsteps:
- name: Checkout Codeuses: actions/checkout@v7
- uses: RoleModel/actions/linting-and-non-system-tests@v3with:
linting_step_required: truelinting_step_command: bundle exec rubocop --fail-level warning --display-only-fail-level-offenses --format githubneeds-compiled-assets: false # Remove this input if you uncommented `needs: compile-assets` above.system-test:
name: Ruby System Testsruns-on: blacksmith-16vcpu-ubuntu-2204timeout-minutes: 10needs: compile-assetsservices:
postgres:
image: postgres:17ports:
- "5432:5432"env:
POSTGRES_USER: postgresPOSTGRES_PASSWORD: passwordsteps:
- name: Checkout Codeuses: actions/checkout@v7# Custom install steps may be added between checkout & test run if needed. e.g.# If your application processes ActiveStorage::Variant records you probably need the following step:
- run: | sudo apt-get update sudo apt-get install -y libvips - uses: RoleModel/actions/system-tests@v3with:
failure-screenshot-dir: tmp/screenshots # if you've configured capybara to be compatible with the tmp:clear taskweb-driver: playwright # remove this input to use the default value (selenium)# completely optional job (for Rails projects only) - outputs a stats table in your workflow's summary pageproject-stats:
name: Project Statsruns-on: blacksmith-4vcpu-ubuntu-2204timeout-minutes: 5steps:
- name: Checkout Codeuses: actions/checkout@v7
- name: Capture Project Statsuses: RoleModel/actions/project-statsThis is using anothrNick/github-tag-action to automatically
post version tags when a commit is merged to master. Unless you include #patch or #major in your commit message,
it will automatically create a new tag a minor version higher. #none will skip tagging altogether.