2024-12-15 20:32:18 +01:00
|
|
|
name: 'Nix Flake Outputs Size Report'
|
|
|
|
author: Jalil David Salamé Messina
|
|
|
|
description: |
|
|
|
|
Use `nix path-info` to query the size of flake outputs and produce a markdown
|
|
|
|
report.
|
|
|
|
|
|
|
|
You can post this report as a comment to the PR associated with the current
|
|
|
|
branch and/or export the report as a markdown artifact.
|
|
|
|
|
2024-12-18 21:45:21 +01:00
|
|
|
Requires `nix`, `jq`, `curl`, `sed`, `gunzip`, `tar` and `coreutils` to be in
|
|
|
|
the runner's path.
|
2024-12-15 20:32:18 +01:00
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
- name: Generate size report
|
|
|
|
uses: https://git.salame.cl/jalil/nix-flake-outputs-size@main
|
|
|
|
with: # Default values
|
|
|
|
comment-on-pr: 'true'
|
|
|
|
generate-artifact: 'false'
|
|
|
|
artifact-name: 'size-report.md'
|
2024-12-18 10:50:36 +01:00
|
|
|
base-branch: ${{ github.base_ref }} # set to e.g. main if not triggered by a pull_request
|
|
|
|
job-name: '' # set to the name of this job if you want to enable comparisons
|
2024-12-15 20:32:18 +01:00
|
|
|
```
|
|
|
|
inputs:
|
|
|
|
comment-on-pr:
|
|
|
|
description: Comment the report on the PR associated with the current branch.
|
|
|
|
default: 'true'
|
|
|
|
generate-artifact:
|
|
|
|
description: Export the generated markdown document as an artifact.
|
|
|
|
default: 'false'
|
|
|
|
artifact-name:
|
|
|
|
description: The name of the generated artifact.
|
2024-12-17 23:15:39 +01:00
|
|
|
default: report.json
|
2024-12-18 10:50:36 +01:00
|
|
|
base-branch:
|
|
|
|
description: |
|
|
|
|
The name of the base branch, defaults to github.base_ref which is only
|
|
|
|
available in pull_request triggered workflows, for other workflows
|
|
|
|
specify it manually.
|
|
|
|
|
|
|
|
It will try to download the generated artifact from this branch so make
|
|
|
|
sure `generate-artifacte: true` when the workflow is running on that
|
|
|
|
branch.
|
|
|
|
default: ${{ github.base_ref }}
|
|
|
|
job-name:
|
|
|
|
description: |
|
|
|
|
The name of the job running this action. If not set, no comparisons can
|
|
|
|
be made.
|
|
|
|
default: ''
|
2024-12-18 21:15:52 +01:00
|
|
|
private-repo-workaround:
|
|
|
|
description: |
|
|
|
|
Forgejo doesn't support downloading artifacts through the API [see
|
|
|
|
codeberg.org/forgejo/forgejo#6315](https://codeberg.org/forgejo/forgejo/issues/6315).
|
|
|
|
|
|
|
|
As a workaround, checkout the base branch and regenerate the report.
|
|
|
|
|
|
|
|
This is very innefficient T-T and slow.
|
|
|
|
default: 'false'
|
2024-12-15 20:32:18 +01:00
|
|
|
outputs:
|
|
|
|
runs:
|
|
|
|
using: 'composite'
|
|
|
|
steps:
|
|
|
|
- name: Create report
|
2024-12-15 20:41:14 +01:00
|
|
|
run: |
|
2024-12-17 23:15:39 +01:00
|
|
|
"$GITHUB_ACTION_PATH/create-report.sh" > report.json
|
2024-12-15 20:32:18 +01:00
|
|
|
- name: Upload Artifact
|
|
|
|
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
|
2024-12-15 20:49:57 +01:00
|
|
|
if: inputs.generate-artifact == 'true'
|
2024-12-15 20:32:18 +01:00
|
|
|
with:
|
2024-12-17 23:15:39 +01:00
|
|
|
path: report.json
|
2024-12-15 20:49:57 +01:00
|
|
|
name: ${{ inputs.artifact-name }}
|
2024-12-15 21:11:15 +01:00
|
|
|
- name: Comment Report
|
2024-12-15 20:49:57 +01:00
|
|
|
if: inputs.comment-on-pr == 'true'
|
2024-12-18 10:50:36 +01:00
|
|
|
env:
|
|
|
|
ARTIFACT_NAME: ${{ inputs.artifact-name }}
|
|
|
|
HEAD_BRANCH: ${{ inputs.base-branch }}
|
|
|
|
JOB_NAME: ${{ inputs.job-name }}
|
2024-12-18 21:15:52 +01:00
|
|
|
PRIVATE_REPO: ${{ inputs.private-repo-workaround }}
|
2024-12-15 20:32:18 +01:00
|
|
|
run: |
|
2024-12-18 22:20:27 +01:00
|
|
|
if "$GITHUB_ACTION_PATH/retrieve-old-report.sh" && [ -f old-report.json ]; then
|
|
|
|
log "Reporting on sizes and comparing to sizes in $HEAD_BRANCH"
|
2024-12-18 21:15:52 +01:00
|
|
|
"$GITHUB_ACTION_PATH/comment_on_pr.sh" report.json old-report.json
|
2024-12-18 22:20:27 +01:00
|
|
|
else
|
|
|
|
log 'Reporting on sizes'
|
|
|
|
"$GITHUB_ACTION_PATH/comment_on_pr.sh" report.json
|
2024-12-18 10:50:36 +01:00
|
|
|
fi
|