diff --git a/.github/workflows/version-and-tag.yml b/.github/workflows/version-and-tag.yml index 4dc7540..5b4fbcf 100644 --- a/.github/workflows/version-and-tag.yml +++ b/.github/workflows/version-and-tag.yml @@ -10,7 +10,7 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: '0' diff --git a/CHANGELOG.md b/CHANGELOG.md index e147894..392d40a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,45 @@ # RoleModel/actions -### 1.0.0 +## [v3.1.0] Feb 25, 2026 + +Add new `project-stats` action which provides a markdown version of +the output of `bin/rails stats` to your workflow's summary page on Github. + +## [v3.0.0] Feb 17, 2026 + +Update Dependency Actions + Add an Input (#6) #major + +- Standardize wording, Quoting, & Capitalization + across composite actions +- Add optional input (needs-compiled-assets) to + linting-and-non-system-tests action (def. true) +- Update Dependency Actions + - actions/cache v4 -> v5 + - actions/setup-node v4 -> v6 + - mikepenz/action-junit-report v4 -> v6 + - browser-actions/setup-chrome v1 -> v2 + - actions/upload-artifact v4 -> v6 + +## [v2.0.0] Apr 11, 2025 + +We originally had a shared workflow that contained all of these actions, but that +was too restrictive. Some projects needed special things to happen (custom install +step, setting up special ENV variables, or needing special secrets that we didn't want +to pass into the composite actions). As an alternative strategy, we're going to provide +many "composite" actions which you can reference from your projects `.github/workflows/ci.yml`. + +New Composite Actions: + +- compile assets +- non system tests +- and system tests + +## [v1.0.0] Feb 18, 2025 + - Add `test-cleanup` action to save logs -- Add `test-runtime-analyzer` action to post test runtimes \ No newline at end of file +- Add `test-runtime-analyzer` action to post test runtimes + +[v3.1.0]: https://github.com/RoleModel/actions/releases/tag/v3.1.0 +[v3.0.0]: https://github.com/RoleModel/actions/releases/tag/v3.0.0 +[v2.0.0]: https://github.com/RoleModel/actions/releases/tag/v2.0.0 +[v1.0.0]: https://github.com/RoleModel/actions/releases/tag/v1.0.0 diff --git a/README.md b/README.md index 7952745..d04fa78 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,16 @@ # RoleModel/actions + Shared Github Actions ## test-cleanup + 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: + ```yaml - name: Cleanup uses: RoleModel/actions/test-cleanup@v3 @@ -16,24 +19,30 @@ Example: ``` ## test-runtime-analyzer + Posts 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 runtimes - `top-count`: Number of slowest tests to show. Default: 10 Example: + ```yaml - name: Analyze test runtimes uses: RoleModel/actions/test-runtime-analyzer@v3 with: test-output-path: tmp/turbo_rspec_runtime.log ``` + ## Shared workflow actions -This is a combination of three 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. + +This 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. The only inputs are for the linting and non system test action. Neither are required: + - `linting-step-required`: Boolean (default is false). Only needed if you have a linting command - `linting-step-command`: String, `bundle exec rubocop --fail-level warning --display-only-fail-level-offenses --format github` @@ -59,13 +68,13 @@ env: # Otherwise, the only thing that matters is that the value is not nil. jobs: - compile_assets: + compile-assets: name: Compile Assets runs-on: blacksmith-4vcpu-ubuntu-2204 timeout-minutes: 5 steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - uses: RoleModel/actions/compile-assets@v3 id: check-asset-cache @@ -75,7 +84,7 @@ jobs: runs-on: blacksmith-8vcpu-ubuntu-2204 timeout-minutes: 5 # If you have non-system tests that touch the browser, you may need to uncomment the following line. - # needs: compile_assets + # needs: compile-assets services: postgres: image: postgres:17 @@ -87,19 +96,19 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - uses: RoleModel/actions/linting-and-non-system-tests@v3 with: linting_step_required: true linting_step_command: bundle exec rubocop --fail-level warning --display-only-fail-level-offenses --format github - needs-compiled-assets: false # Remove this input if you uncommented `needs: compile_assets` above. + needs-compiled-assets: false # Remove this input if you uncommented `needs: compile-assets` above. system-test: name: Ruby System Tests runs-on: blacksmith-16vcpu-ubuntu-2204 timeout-minutes: 10 - needs: compile_assets + needs: compile-assets services: postgres: image: postgres:17 @@ -111,7 +120,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v6 # 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: @@ -124,9 +133,21 @@ jobs: # you can tell the system-tests action like this: with: failure-screenshot-dir: tmp/screenshots + # completely optional job (for Rails projects only) - outputs a stats table in your workflow's summary page + project-stats: + name: Project Stats + runs-on: blacksmith-4vcpu-ubuntu-2204 + timeout-minutes: 5 + steps: + - name: Checkout Code + uses: actions/checkout@v6 + + - name: Capture Project Stats + uses: RoleModel/actions/project-stats ``` ## Versioning + This is using [anothrNick/github-tag-action](https://github.com/anothrNick/github-tag-action/tree/master) 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. diff --git a/project-stats/action.yml b/project-stats/action.yml new file mode 100644 index 0000000..29df3e5 --- /dev/null +++ b/project-stats/action.yml @@ -0,0 +1,42 @@ +name: Project Stats +description: Runs `bin/rails stats` and converts the output to a Markdown Table for the GitHub Actions summary. +inputs: + install-ruby: + description: > + Whether Ruby & Gems install should be performed before running the command. + Set this to false if your using this action as a step within a larger job that has already setup Ruby. + required: false + default: 'true' + +runs: + using: composite + steps: + - name: Install Ruby and Gems + uses: ruby/setup-ruby@v1 + if: inputs.install-ruby == 'true' + with: + bundler-cache: true + + - name: Run Stats Command and Capture Output + shell: bash + run: | + bin/rails stats | sed -n '/^|/p' | while IFS= read -r line; do + trimmed="${line#|}" + trimmed="${trimmed%|}" + IFS='|' read -ra cells <<< "$trimmed" + row="| " + for cell in "${cells[@]}"; do + cell="$(echo "$cell" | sed 's/^ *//;s/ *$//')" + row+="$cell | " + done + echo "$row" + + if [ -z "$header_done" ]; then + sep="| " + for cell in "${cells[@]}"; do + sep+="--- | " + done + echo "$sep" + header_done=1 + fi + done >> $GITHUB_STEP_SUMMARY diff --git a/test-cleanup/action.yml b/test-cleanup/action.yml index d358697..ea7fec4 100644 --- a/test-cleanup/action.yml +++ b/test-cleanup/action.yml @@ -1,8 +1,10 @@ -name: "Test Cleanup" - +name: Test Cleanup +description: Uploads Test Logs and prints system info to the console after test runs. inputs: artifact-prefix: - type: string + description: > + Prefix for the uploaded artifact name. Full artifact name will be {prefix}-logs. + This is used to differentiate logs from different test runs (e.g. system vs non-system tests). required: true runs: diff --git a/test-runtime-analyzer/action.yml b/test-runtime-analyzer/action.yml index 7fecb73..7a93d7f 100644 --- a/test-runtime-analyzer/action.yml +++ b/test-runtime-analyzer/action.yml @@ -1,16 +1,16 @@ -name: 'Test Runtime Analyzer' -description: 'Analyzes test runtimes and shows the slowest tests' +name: Test Runtime Analyzer +description: Analyzes test runtimes and shows the slowest tests inputs: test-output-path: - description: 'Path to the test output file' + description: Path to the test output file required: true top-count: - description: 'Number of slowest tests to show' + description: Number of slowest tests to show required: false default: '10' runs: - using: "composite" + using: composite steps: - name: Analyze test runtimes shell: bash