Skip to content

Commit cd8ad19

Browse files
authored
Add workflow for testing downstream packages (#7)
1 parent 18a84dc commit cd8ad19

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

.github/workflows/IntegrationTest.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: "Reusable IntegrationTest Workflow"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
julia-version:
7+
description: "Julia version"
8+
default: "1"
9+
required: false
10+
type: string
11+
repo:
12+
description: "Repository name, including the group/user, such as ITensor/ITensors.jl"
13+
required: true
14+
type: string
15+
local-registry-urls:
16+
description: 'Registries besides General to use. Specified by providing the url (https/ssh) to the Github
17+
repositories as a newline (\n) seperated list. Defaults to including the ITensorRegistry
18+
(https://github.com/ITensor/ITensorRegistry.git).'
19+
default: ""
20+
required: false
21+
type: string
22+
23+
jobs:
24+
test:
25+
name: ${{ inputs.repo }}
26+
runs-on: ${{ matrix.os }}
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
os: [ubuntu-latest]
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: julia-actions/setup-julia@v2
35+
with:
36+
version: ${{ inputs.julia-version }}
37+
arch: x64
38+
localregistry: https://github.com/ITensor/ITensorRegistry.git
39+
- uses: julia-actions/julia-buildpkg@latest
40+
- name: Clone Downstream
41+
uses: actions/checkout@v4
42+
with:
43+
repository: ${{ inputs.repo }}
44+
path: downstream
45+
- name: Load this and run the downstream tests
46+
shell: julia --color=yes --project=downstream {0}
47+
run: |
48+
using Pkg
49+
# If provided add local registries
50+
if !isempty("${{ inputs.local-registry-urls }}")
51+
registry_urls = split("${{ inputs.local-registry-urls }}", "\n") .|> string
52+
for registry_url in registry_urls
53+
isempty(registry_url) && continue
54+
Pkg.Registry.add(Pkg.RegistrySpec(; url=registry_url))
55+
end
56+
end
57+
try
58+
# force it to use this PR's version of the package
59+
Pkg.develop(PackageSpec(path=".")) # resolver may fail with main deps
60+
Pkg.update()
61+
Pkg.test(coverage=true) # resolver may fail with test time deps
62+
catch err
63+
err isa Pkg.Resolve.ResolverError || rethrow()
64+
# If we can't resolve that means this is incompatible by SemVer and this is fine
65+
# It means we marked this as a breaking change, so we don't need to worry about
66+
# Mistakenly introducing a breaking change, as we have intentionally made one
67+
@info "Not compatible with this release. No problem." exception=err
68+
exit(0) # Exit immediately, as a success
69+
end

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,41 @@ jobs:
207207
with:
208208
local-registry-urls: "https://github.com/ITensor/ITensorRegistry.git"
209209
```
210+
211+
## IntegrationTest
212+
213+
Test a set of dependencies of the package against the current PR branch
214+
to check if changes in the branch break any downstream tests. If the version
215+
is bumped to indicate a breaking change according to semver, the test passes
216+
since it is safe to register the changes without breaking downstream
217+
packages if they follow semver in their compat versions.
218+
Additionally, if some dependent packages being tested are registered in one or more
219+
local registry, you can specify a list of local registries using their
220+
repository URLs using the `local-registy-urls` option,
221+
which should be a string with registry URLs seperated by a newline character (`\n`).
222+
Here is an example workflow:
223+
224+
```yaml
225+
name: "IntegrationTest"
226+
227+
on:
228+
push:
229+
branches:
230+
- 'main'
231+
tags: '*'
232+
pull_request:
233+
234+
jobs:
235+
integration-test:
236+
name: "IntegrationTest"
237+
strategy:
238+
matrix:
239+
repo:
240+
- 'ITensor/BlockSparseArrays.jl'
241+
- 'ITensor/NamedDimsArrays.jl'
242+
- 'ITensor/TensorAlgebra.jl'
243+
uses: "ITensor/ITensorActions/.github/workflows/IntegrationTest.yml@main"
244+
with:
245+
local-registry-urls: "https://github.com/ITensor/ITensorRegistry.git"
246+
repo: "${{ matrix.repo }}"
247+
```

0 commit comments

Comments
 (0)