Skip to content

Commit

Permalink
Update example script (#4)
Browse files Browse the repository at this point in the history
This is based on some discussion we recently had in SciML, see SciML/MuladdMacro.jl#26 and SciML/MuladdMacro.jl#29
  • Loading branch information
ranocha authored Dec 6, 2022
1 parent 36b481d commit c0cb892
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,66 @@
# julia-invalidations
Uses [`SnoopCompile.@snoopr`](https://timholy.github.io/SnoopCompile.jl/stable/snoopr/) to evaluate number of invalidations caused by `using Package` or a provided script
Uses [`SnoopCompile.@snoopr`](https://timholy.github.io/SnoopCompile.jl/stable/snoopr/)
to evaluate number of invalidations caused by `using Package` or a provided script


## Usage

This is a composite github action, that can be inserted into a github action on the target repo to evaluate number of invalidations

For instance, the example below will evaluate number of invalidations that branch/PR has vs. master, and fail if the number increases. Both runs happen on the same julia nightly, so that the comparison in # invalidations is less sensitive to changes in base.
For instance, the example below will evaluate number of invalidations that branch/PR has vs. the default branch, and fail if the number increases.
Both runs happen on the same julia version, so that the comparison in # invalidations is less sensitive to changes in Julia.

- Create an action file in the desired repo. i.e. `.github/workflows/InvalidationFlagger.yml`
- Create an action file in the desired repo. i.e. `.github/workflows/Invalidations.yml`

```
name: Invalidations
on: [push, pull_request]
on:
pull_request:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: always.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
evaluate:
# Only run on PRs to the default branch.
# In the PR trigger above branches can be specified only explicitly whereas this check should work for master, main, or any other default branch
if: github.base_ref == github.event.repository.default_branch
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@v1
with:
version: 'nightly'
- uses: actions/checkout@v2
- uses: julia-actions/julia-buildpkg@latest
version: '1'
- uses: actions/checkout@v3
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-invalidations@v1
id: invs_pr
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
ref: 'master'
- uses: julia-actions/julia-buildpkg@latest
ref: ${{ github.event.repository.default_branch }}
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-invalidations@v1
id: invs_master
id: invs_default
- name: Report invalidation counts
run: |
echo "Invalidations on master: ${{ steps.invs_master.outputs.total }} (${{ steps.invs_master.outputs.deps }} via deps)"
echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)"
shell: bash
- name: PR doesn't increase number of invalidations
run: |
if (( ${{ steps.invs_pr.outputs.total }} > ${{ steps.invs_master.outputs.total }} )); then
exit 1
fi
shell: bash
echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY
echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY
- name: Check if the PR does increase number of invalidations
if: steps.invs_pr.outputs.total > steps.invs_default.outputs.total

This comment has been minimized.

Copy link
@KristofferC

KristofferC Jul 12, 2024

Contributor

This change broke the workflow (numerical comparison -> string comparison)

run: exit 1
```

By default, the action will evaluate `using Package` where `Package` is the name of the julia repo that the action runs on.
A custom script can be provided by passing `test_script`. Note that both runs should be given the same script

i.e.
```
- uses: julia-actions/julia-invalidations@master
- uses: julia-actions/julia-invalidations@v1
id: invs_pr
with:
test_script: 'using Package; Package.foo(1)'
Expand Down

0 comments on commit c0cb892

Please sign in to comment.