-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regression tests & benchmark #929
Draft
epolack
wants to merge
1
commit into
JuliaMolSim:master
Choose a base branch
from
epolack:pkgbenchmark
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: Regression | ||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: ['*'] | ||
pull_request: | ||
schedule: | ||
- cron: '0 4 * * 6' # Run every Saturday | ||
concurrency: | ||
# Skip intermediate builds: always. | ||
# Cancel intermediate builds: only if it is a pull request build. | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} | ||
|
||
jobs: | ||
test: | ||
name: Benchmarking ${{ matrix.description }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- {description: run, payload: benchmarks.jl } | ||
- {description: load, payload: load.jl } | ||
steps: | ||
# Remove older benchmark comment | ||
- name: pr-deleter | ||
uses: maheshrayas/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
org: <orgname> | ||
repo: <repo> | ||
user: github-actions[bot] | ||
issue: ${{github.event.number}} | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Julia stable | ||
uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: '1.9' | ||
arch: x64 | ||
|
||
- uses: julia-actions/cache@v1 | ||
with: | ||
include-matrix: false | ||
- uses: julia-actions/julia-buildpkg@v1 | ||
|
||
- name: Install dependencies | ||
run: | | ||
julia --project=benchmark -e ' | ||
using Pkg | ||
Pkg.develop(PackageSpec(; path=pwd())) | ||
Pkg.instantiate()' | ||
|
||
- name: Run benchmarks against master | ||
# Remove baseline once merged. Regression tests will only work after this is merged | ||
# in master. | ||
run: | | ||
julia --project=benchmark -e " | ||
using BenchmarkCI | ||
baseline = \"HEAD\" | ||
script = \"\$(pwd())/benchmark/${{ matrix.payload }}\" | ||
BenchmarkCI.judge(; baseline, script, retune=true)" | ||
if: ${{ github.event_name == 'pull_request' }} | ||
|
||
- name: Run benchmarks against last release | ||
run: | | ||
julia --project=benchmark -e " | ||
import Pkg | ||
baseline = \"v\" * Pkg.TOML.parsefile(\"Project.toml\")[\"version\"] | ||
script = \"\$(pwd())/benchmark/${{ matrix.payload }}\" | ||
using BenchmarkCI | ||
BenchmarkCI.judge(; baseline, script, retune=true)" | ||
if: ${{ github.event_name == 'schedule' || | ||
github.event.push.ref == 'refs/heads/master' }} | ||
|
||
- name: Print judgement | ||
run: | | ||
julia --project=benchmark -e ' | ||
using BenchmarkCI | ||
BenchmarkCI.displayjudgement()' | ||
|
||
- name: Post results | ||
run: | | ||
julia --project=benchmark -e ' | ||
using BenchmarkCI | ||
BenchmarkCI.postjudge()' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Is report successful | ||
run: | | ||
res=$(julia --project=benchmark -e ' | ||
using BenchmarkCI | ||
BenchmarkCI.displayjudgement()' | grep --count ':x:') | ||
if [[ $res -gt 1 ]]; then exit 1; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ Manifest.toml | |
/LocalPreferences.toml | ||
.vscode | ||
.CondaPkg | ||
/.benchmarkci | ||
/benchmark/**/*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[deps] | ||
AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a" | ||
BenchmarkCI = "20533458-34a3-403d-a444-e18f38190b5b" | ||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" | ||
DFTK = "acf6eb54-70d9-11e9-0013-234b7a5f5337" | ||
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" | ||
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" | ||
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" | ||
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" | ||
UnitfulAtomic = "a7773ee8-282e-5fa2-be4e-bd808c38a91a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using BenchmarkTools | ||
using TestItemRunner | ||
|
||
const SUITE = BenchmarkGroup() | ||
|
||
@run_package_tests filter=ti->(:regression ∈ ti.tags) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[deps] | ||
AtomsIO = "1692102d-eeb4-4df9-807b-c9517f998d44" | ||
BenchmarkCI = "20533458-34a3-403d-a444-e18f38190b5b" | ||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" | ||
DFTK = "acf6eb54-70d9-11e9-0013-234b7a5f5337" | ||
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
MKL = "33e6dc65-8f57-5167-99aa-e5a354878fb2" | ||
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" | ||
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using BenchmarkTools | ||
using TestItemRunner | ||
|
||
function run_scenario(scenario, complexity) | ||
scenario_filter(i) = occursin(string(scenario), i.filename) && complexity ∈ i.tags | ||
@run_package_tests filter=scenario_filter | ||
end | ||
|
||
all_scenarios() = [:AlSiO2H, :Cr19, :Fe2MnAl, :Mn2RuGa, :WFe] | ||
function make_suite(; scenarios=all_scenarios(), complexity=:debug) | ||
@assert complexity ∈ [:debug, :small, :full] | ||
@assert all(scenarios .∈ Ref(all_scenarios())) | ||
|
||
suite = BenchmarkGroup() | ||
for scenario in scenarios | ||
suite[scenario] = @benchmarkable run_scenario($scenario, $complexity) | ||
end | ||
suite | ||
end | ||
|
||
const SUITE = make_suite(; scenarios=[:AlSiO2H]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
ROOTPATH = abspath(joinpath(@__DIR__, "../..")) | ||
import Pkg | ||
Pkg.activate(@__DIR__) | ||
if !isfile(joinpath(@__DIR__, "Manifest.toml")) | ||
Pkg.develop(Pkg.PackageSpec(; path=ROOTPATH)) | ||
Pkg.instantiate() | ||
end | ||
|
||
import BenchmarkCI | ||
import LibGit2 | ||
|
||
""" | ||
Launch with | ||
```julia | ||
julia --project=benchmark/humongous -e ' | ||
include("benchmark/humongous/run.jl") | ||
run_benchmark()' | ||
``` | ||
""" | ||
function run_benchmark(; retune=false, baseline="origin/master", target="HEAD", | ||
script=nothing) | ||
mktempdir(mktempdir()) do repo_dir # TestItemRunner needs access to parent directory as well. | ||
project = joinpath(ROOTPATH, "benchmark", "humongous") | ||
# Workaround to be able to benchmark releases before the use of PkgBenchmark. | ||
# WARN: In this case, we need PkgBenchmark to be installed globally. | ||
if isnothing(script) | ||
# We run the default benchmark. | ||
script = joinpath(project, "benchmarks.jl") | ||
else | ||
occursin(ROOTPATH, abspath(script)) && | ||
error("Script should be outside the repository.") | ||
end | ||
script_copy = joinpath(repo_dir, "benchmarks.jl") | ||
cp(script, script_copy) | ||
|
||
LibGit2.clone("https://github.com/epolack/DFTK-testproblems", | ||
joinpath(repo_dir, "test")) | ||
|
||
BenchmarkCI.judge(; baseline, target, retune, script=script_copy, project) | ||
|
||
BenchmarkCI.displayjudgement() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using BenchmarkTools | ||
|
||
const SUITE = BenchmarkGroup() | ||
|
||
julia_cmd = unsafe_string(Base.JLOptions().julia_bin) | ||
SUITE["load"] = @benchmarkable run(`$julia_cmd \ | ||
--startup-file=no \ | ||
--project=$(Base.active_project()) \ | ||
-e 'using DFTK'`) | ||
SUITE["pecompilation"] = | ||
@benchmarkable run(`$julia_cmd \ | ||
--startup-file=no \ | ||
--project=$(Base.active_project()) \ | ||
-e 'Base.compilecache(Base.identify_package("DFTK"))'`) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May not be really useful. But would allow to run some regression tests as part as the standard test set. Otherwise, it will crash.
Remove?