From 8789cdf44b355d345b9d370c25b94a583c81e603 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Mon, 8 Jul 2024 22:44:39 -0700 Subject: [PATCH 1/2] test: more explicit imports testing --- Project.toml | 2 +- test/qa_tests.jl | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index e66ab80..0517ad8 100644 --- a/Project.toml +++ b/Project.toml @@ -32,7 +32,7 @@ Aqua = "0.8.7" CUDA = "5.3.2" ChainRulesCore = "1.23" Documenter = "1.5.0" -ExplicitImports = "1.6.0" +ExplicitImports = "1.9.0" GPUArrays = "10.2" GPUArraysCore = "0.1.6" LinearAlgebra = "1.10" diff --git a/test/qa_tests.jl b/test/qa_tests.jl index e4a4a6e..a82cc74 100644 --- a/test/qa_tests.jl +++ b/test/qa_tests.jl @@ -11,6 +11,16 @@ end @test check_no_implicit_imports(WeightInitializers) === nothing @test check_no_stale_explicit_imports(WeightInitializers) === nothing @test check_no_self_qualified_accesses(WeightInitializers) === nothing + @test check_all_explicit_imports_via_owners(WeightInitializers) === nothing + @test check_all_qualified_accesses_via_owners(WeightInitializers) === nothing + @test_broken check_all_explicit_imports_are_public(WeightInitializers) === nothing # mostly upstream problems + + try + acc = check_all_qualified_accesses_are_public(WeightInitializers) + @test acc === nothing + catch + @test_broken check_all_qualified_accesses_are_public(WeightInitializers) === nothing + end end @testitem "doctests: Quality Assurance" begin From 5916393e3da1a986c1897ec66aa988c56f78caa5 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Mon, 8 Jul 2024 23:21:05 -0700 Subject: [PATCH 2/2] ci: run only necessary tests --- .buildkite/pipeline.yml | 236 +++--------------------- .buildkite/scripts/diff.sh | 13 ++ .buildkite/scripts/downstream.jl | 25 +++ .buildkite/scripts/find_branch_point.sh | 6 + .buildkite/testing.yml | 167 +++++++++++++++++ .github/workflows/CI.yml | 7 +- test/qa_tests.jl | 2 +- 7 files changed, 242 insertions(+), 214 deletions(-) create mode 100755 .buildkite/scripts/diff.sh create mode 100644 .buildkite/scripts/downstream.jl create mode 100755 .buildkite/scripts/find_branch_point.sh create mode 100644 .buildkite/testing.yml diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index d5cae77..2c00e63 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,212 +1,26 @@ steps: - - group: ":julia: CUDA GPU" - steps: - - label: ":julia: Julia {{matrix.julia}} + CUDA GPU" - plugins: - - JuliaCI/julia#v1: - version: "{{matrix.julia}}" - - JuliaCI/julia-test#v1: - test_args: "--quickfail" - - JuliaCI/julia-coverage#v1: - codecov: true - dirs: - - src - - ext - agents: - queue: "juliagpu" - cuda: "*" - env: - BACKEND_GROUP: "CUDA" - if: build.message !~ /\[skip tests\]/ - timeout_in_minutes: 240 - matrix: - setup: - julia: - - "1" - - # Downstream CUDA Tests - - group: ":telescope: Downstream CUDA" - steps: - - label: ":julia: {{matrix.repo}} (Julia {{matrix.julia}} + CUDA GPU)" - plugins: - - JuliaCI/julia#v1: - version: "{{matrix.julia}}" - - JuliaCI/julia-coverage#v1: - codecov: true - dirs: - - src - command: | - julia --code-coverage=user --color=yes --project -e ' - using Pkg - - repo = ENV["DOWNSTREAM_TEST_REPO"] - - println("--- :julia: Instantiating project") - withenv("JULIA_PKG_PRECOMPILE_AUTO" => 0) do - Pkg.instantiate() - - try - Pkg.develop(repo) - println("+++ :julia: Running tests") - Pkg.test("$(repo)"; coverage=true) - catch err - err isa Pkg.Resolve.ResolverError || rethrow() - @info "Not compatible with this release. No problem." exception=err - exit(0) - end - end - - println("+++ :julia: Finished Downstream Test")' - agents: - queue: "juliagpu" - cuda: "*" - env: - BACKEND_GROUP: "CUDA" - DOWNSTREAM_TEST_REPO: "{{matrix.repo}}" - if: build.message !~ /\[skip tests\]/ || build.message !~ /\[skip downstream\]/ - timeout_in_minutes: 240 - matrix: - setup: - julia: - - "1" - repo: - - "Lux" - - "Boltz" - - - group: ":julia: AMD GPU" - steps: - - label: ":julia: Julia: {{matrix.julia}} + AMD GPU" - plugins: - - JuliaCI/julia#v1: - version: "{{matrix.julia}}" - - JuliaCI/julia-test#v1: - test_args: "--quickfail" - - JuliaCI/julia-coverage#v1: - codecov: true - dirs: - - src - - ext - env: - JULIA_AMDGPU_CORE_MUST_LOAD: "1" - JULIA_AMDGPU_HIP_MUST_LOAD: "1" - JULIA_AMDGPU_DISABLE_ARTIFACTS: "1" - BACKEND_GROUP: "AMDGPU" - agents: - queue: "juliagpu" - rocm: "*" - rocmgpu: "*" - if: build.message !~ /\[skip tests\]/ - timeout_in_minutes: 60 - matrix: - setup: - julia: - - "1" - - # Downstream AMDGPU Tests - - group: ":telescope: Downstream AMD GPU" - steps: - - label: ":julia: {{matrix.repo}} (Julia {{matrix.julia}} + AMD GPU)" - plugins: - - JuliaCI/julia#v1: - version: "{{matrix.julia}}" - - JuliaCI/julia-coverage#v1: - codecov: true - dirs: - - src - command: | - julia --code-coverage=user --color=yes --project -e ' - using Pkg - - repo = ENV["DOWNSTREAM_TEST_REPO"] - - println("--- :julia: Instantiating project") - withenv("JULIA_PKG_PRECOMPILE_AUTO" => 0) do - Pkg.instantiate() - - try - Pkg.develop(repo) - println("+++ :julia: Running tests") - Pkg.test("$(repo)"; coverage=true) - catch err - err isa Pkg.Resolve.ResolverError || rethrow() - @info "Not compatible with this release. No problem." exception=err - exit(0) - end - end - - println("+++ :julia: Finished Downstream Test")' - agents: - queue: "juliagpu" - rocm: "*" - rocmgpu: "*" - env: - BACKEND_GROUP: "AMDGPU" - JULIA_AMDGPU_CORE_MUST_LOAD: "1" - JULIA_AMDGPU_HIP_MUST_LOAD: "1" - JULIA_AMDGPU_DISABLE_ARTIFACTS: "1" - DOWNSTREAM_TEST_REPO: "{{matrix.repo}}" - if: build.message !~ /\[skip tests\]/ || build.message !~ /\[skip downstream\]/ - timeout_in_minutes: 240 - matrix: - setup: - julia: - - "1" - repo: - - "Lux" - - "Boltz" - - - group: ":julia: Metal GPU" - steps: - - label: ":julia: Julia: {{matrix.julia}} + Metal" - plugins: - - JuliaCI/julia#v1: - version: "{{matrix.julia}}" - - JuliaCI/julia-test#v1: - test_args: "--quickfail" - # - JuliaCI/julia-coverage#v1: - # codecov: true - # dirs: - # - src - # - ext - agents: - queue: "juliaecosystem" - os: "macos" - arch: "aarch64" - env: - BACKEND_GROUP: "Metal" - if: build.message !~ /\[skip tests\]/ - timeout_in_minutes: 60 - matrix: - setup: - julia: - - "1" - - - group: ":julia: oneAPI GPU" - steps: - - label: ":julia: Julia: {{matrix.julia}} + oneAPI" - plugins: - - JuliaCI/julia#v1: - version: "{{matrix.julia}}" - - JuliaCI/julia-test#v1: - test_args: "--quickfail" - - JuliaCI/julia-coverage#v1: - codecov: true - dirs: - - src - - ext - env: - BACKEND_GROUP: "oneAPI" - agents: - queue: "juliagpu" - intel: "*" - if: build.message !~ /\[skip tests\]/ - timeout_in_minutes: 60 - matrix: - setup: - julia: - - "1" - -env: - RETESTITEMS_NWORKERS: 8 - RETESTITEMS_NWORKER_THREADS: 2 - SECRET_CODECOV_TOKEN: "DpNKbuKYRX40vpyJCfTvQmxwls1hlCUWiZX4pnsukt9E8u4pf0WUcIroRv2UDDbGYjuk5izmZ9yAhZZhiGMhjFF/TIji3JiYe1sXWdfSrNk0N2+CNoXo+CIi3JvS7mB+YAIUTEi2Xph+L7R0d+It079PEispqVv4bdRuqgSbY7Rn3NSsoV1cB8uUaVFBJH4EewC6Hceg80QW7q+CBru+QECudKbAWnRVLoizRsgzIld+gTUqsI1PhR+vSpD+AfZzhVxmff55ttVcMUFGnL3w4L74qoLVPET52/GPLCOi3RLGSzBJjebSBqqKOwesT9xJ4yaZ21AEzyeOm86YRc2WYg==;U2FsdGVkX1/eBwyJ7Of++vKyAWDSBvSdJeiKmVmlaVKFU5CHejM+sDlSZWH/WmoBatLcqH+eUVEGXC+oWl5riw==" + - label: "Triggering Pipelines (Pull Request)" + if: "build.pull_request.base_branch == 'main'" + agents: + queue: "juliagpu" + plugins: + - monebag/monorepo-diff#v2.5.9: + diff: ".buildkite/scripts/diff.sh $BUILDKITE_COMMIT" + interpolation: false + watch: + - path: + - "src/" + - "ext/" + - "test/" + - "Project.toml" + - ".buildkite/" + config: + command: "buildkite-agent pipeline upload .buildkite/testing.yml" + agents: + queue: "juliagpu" + + - label: "Triggering Pipelines (Main Branch / Tag)" + if: build.branch == "main" || build.tag != null + agents: + queue: "juliagpu" + command: "buildkite-agent pipeline upload .buildkite/testing.yml" diff --git a/.buildkite/scripts/diff.sh b/.buildkite/scripts/diff.sh new file mode 100755 index 0000000..b73437f --- /dev/null +++ b/.buildkite/scripts/diff.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -ueo pipefail + +# Script to output the diff where the branch was created +# Usage: ./diff.sh $BUILDKITE_COMMIT + +COMMIT_HASH=$1 +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +BRANCH_POINT_COMMIT=$($SCRIPT_DIR/find_branch_point.sh "$COMMIT_HASH") +echo >&2 "Cannot find latest build. Running diff against: $BRANCH_POINT_COMMIT" +diff=$(git diff --name-only "$BRANCH_POINT_COMMIT") +echo "$diff" diff --git a/.buildkite/scripts/downstream.jl b/.buildkite/scripts/downstream.jl new file mode 100644 index 0000000..2948deb --- /dev/null +++ b/.buildkite/scripts/downstream.jl @@ -0,0 +1,25 @@ +using Pkg + +repo = ARGS[1] +if contains(repo, "#") + repo, group = split(repo, "#") +else + group = ARGS[2] +end + +println("--- :julia: Instantiating project") +withenv("JULIA_PKG_PRECOMPILE_AUTO" => 0, "GROUP" => group, "BACKEND_GROUP" => group) do + Pkg.instantiate() + + try + Pkg.develop(repo) + println("+++ :julia: Running tests") + Pkg.test("$(repo)"; coverage=true) + catch err + err isa Pkg.Resolve.ResolverError || rethrow() + @info "Not compatible with this release. No problem." exception=err + exit(0) + end +end + +println("+++ :julia: Finished Downstream Test") diff --git a/.buildkite/scripts/find_branch_point.sh b/.buildkite/scripts/find_branch_point.sh new file mode 100755 index 0000000..f829535 --- /dev/null +++ b/.buildkite/scripts/find_branch_point.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -ue + +diff -u <(git rev-list --first-parent "$1") \ + <(git rev-list --first-parent main) | \ + sed -ne 's/^ //p' | head -1 diff --git a/.buildkite/testing.yml b/.buildkite/testing.yml new file mode 100644 index 0000000..cbb6c25 --- /dev/null +++ b/.buildkite/testing.yml @@ -0,0 +1,167 @@ +steps: + - group: ":julia: CUDA GPU" + steps: + - label: ":julia: Julia {{matrix.julia}} + CUDA GPU" + plugins: + - JuliaCI/julia#v1: + version: "{{matrix.julia}}" + - JuliaCI/julia-test#v1: + test_args: "--quickfail" + - JuliaCI/julia-coverage#v1: + codecov: true + dirs: + - src + - ext + agents: + queue: "juliagpu" + cuda: "*" + env: + BACKEND_GROUP: "CUDA" + if: build.message !~ /\[skip tests\]/ && build.message !~ /\[skip ci\]/ + timeout_in_minutes: 60 + matrix: + setup: + julia: + - "1" + + - group: ":telescope: Downstream CUDA" + steps: + - label: ":julia: {{matrix.repo}} (Julia 1 + CUDA GPU)" + plugins: + - JuliaCI/julia#v1: + version: "1" + - JuliaCI/julia-coverage#v1: + codecov: true + dirs: + - src + - ext + command: julia --code-coverage=user --color=yes --project .buildkite/scripts/downstream.jl "{{matrix.repo}}" "CUDA" + agents: + queue: "juliagpu" + cuda: "*" + env: + RETESTITEMS_NWORKERS: 2 + if: build.message !~ /\[skip tests\]/ && build.message !~ /\[skip downstream\]/ && build.message !~ /\[skip ci\]/ && build.pull_request.labels includes "run downstream test" + timeout_in_minutes: 60 + matrix: + setup: + repo: + - "Boltz" + - "Lux" + + - group: ":julia: AMD GPU" + steps: + - label: ":julia: Julia: {{matrix.julia}} + AMD GPU" + plugins: + - JuliaCI/julia#v1: + version: "{{matrix.julia}}" + - JuliaCI/julia-test#v1: + test_args: "--quickfail" + - JuliaCI/julia-coverage#v1: + codecov: true + dirs: + - src + - ext + env: + JULIA_AMDGPU_CORE_MUST_LOAD: "1" + JULIA_AMDGPU_HIP_MUST_LOAD: "1" + JULIA_AMDGPU_DISABLE_ARTIFACTS: "1" + BACKEND_GROUP: "AMDGPU" + agents: + queue: "juliagpu" + rocm: "*" + rocmgpu: "*" + if: build.message !~ /\[skip tests\]/ && build.message !~ /\[skip ci\]/ + timeout_in_minutes: 60 + matrix: + setup: + julia: + - "1" + + - group: ":telescope: Downstream AMD GPU" + steps: + - label: ":julia: {{matrix.repo}} (Julia 1 + AMD GPU)" + plugins: + - JuliaCI/julia#v1: + version: "1" + - JuliaCI/julia-coverage#v1: + codecov: true + dirs: + - src + - ext + command: julia --code-coverage=user --color=yes --project .buildkite/scripts/downstream.jl "{{matrix.repo}}" "AMDGPU" + agents: + queue: "juliagpu" + rocm: "*" + rocmgpu: "*" + env: + JULIA_AMDGPU_CORE_MUST_LOAD: "1" + JULIA_AMDGPU_HIP_MUST_LOAD: "1" + JULIA_AMDGPU_DISABLE_ARTIFACTS: "1" + RETESTITEMS_NWORKERS: 2 + if: build.message !~ /\[skip tests\]/ && build.message !~ /\[skip downstream\]/ && build.message !~ /\[skip ci\]/ && build.pull_request.labels includes "run downstream test" + timeout_in_minutes: 60 + matrix: + setup: + repo: + - "Boltz" + - "Lux" + + - group: ":julia: Metal GPU" + steps: + - label: ":julia: Julia: {{matrix.julia}} + Metal" + plugins: + - JuliaCI/julia#v1: + version: "{{matrix.julia}}" + - JuliaCI/julia-test#v1: + test_args: "--quickfail" + # - JuliaCI/julia-coverage#v1: + # codecov: true + # dirs: + # - src + # - ext + agents: + queue: "juliaecosystem" + os: "macos" + arch: "aarch64" + env: + BACKEND_GROUP: "Metal" + if: build.message !~ /\[skip tests\]/ + timeout_in_minutes: 60 + matrix: + setup: + julia: + - "1" + + - group: ":julia: oneAPI GPU" + steps: + - label: ":julia: Julia: {{matrix.julia}} + oneAPI" + plugins: + - JuliaCI/julia#v1: + version: "{{matrix.julia}}" + - JuliaCI/julia-test#v1: + test_args: "--quickfail" + - JuliaCI/julia-coverage#v1: + codecov: true + dirs: + - src + - ext + env: + BACKEND_GROUP: "oneAPI" + agents: + queue: "juliagpu" + intel: "*" + if: build.message !~ /\[skip tests\]/ + timeout_in_minutes: 60 + matrix: + setup: + julia: + - "1" + +env: + RETESTITEMS_NWORKERS: 8 + RETESTITEMS_NWORKER_THREADS: 2 + RETESTITEMS_TESTITEM_TIMEOUT: 3600 + JULIA_PKG_SERVER: "" + JULIA_NUM_THREADS: 4 + SECRET_CODECOV_TOKEN: "DpNKbuKYRX40vpyJCfTvQmxwls1hlCUWiZX4pnsukt9E8u4pf0WUcIroRv2UDDbGYjuk5izmZ9yAhZZhiGMhjFF/TIji3JiYe1sXWdfSrNk0N2+CNoXo+CIi3JvS7mB+YAIUTEi2Xph+L7R0d+It079PEispqVv4bdRuqgSbY7Rn3NSsoV1cB8uUaVFBJH4EewC6Hceg80QW7q+CBru+QECudKbAWnRVLoizRsgzIld+gTUqsI1PhR+vSpD+AfZzhVxmff55ttVcMUFGnL3w4L74qoLVPET52/GPLCOi3RLGSzBJjebSBqqKOwesT9xJ4yaZ21AEzyeOm86YRc2WYg==;U2FsdGVkX1/eBwyJ7Of++vKyAWDSBvSdJeiKmVmlaVKFU5CHejM+sDlSZWH/WmoBatLcqH+eUVEGXC+oWl5riw==" diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index df19795..489a020 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -73,8 +73,8 @@ jobs: julia-version: ["1"] os: [ubuntu-latest] package: - - { user: LuxDL, repo: Lux.jl, group: All } - - { user: LuxDL, repo: Boltz.jl, group: All } + - { user: LuxDL, repo: Lux.jl, group: CPU } + - { user: LuxDL, repo: Boltz.jl, group: CPU } steps: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v2 @@ -104,6 +104,9 @@ jobs: @info "Not compatible with this release. No problem." exception=err exit(0) # Exit immediately, as a success end + env: + GROUP: ${{ matrix.package.group }} + BACKEND_GROUP: ${{ matrix.package.group }} - uses: julia-actions/julia-processcoverage@v1 - uses: codecov/codecov-action@v4 with: diff --git a/test/qa_tests.jl b/test/qa_tests.jl index a82cc74..63f5296 100644 --- a/test/qa_tests.jl +++ b/test/qa_tests.jl @@ -15,7 +15,7 @@ end @test check_all_qualified_accesses_via_owners(WeightInitializers) === nothing @test_broken check_all_explicit_imports_are_public(WeightInitializers) === nothing # mostly upstream problems - try + try # FIXME: Soft fail for now acc = check_all_qualified_accesses_are_public(WeightInitializers) @test acc === nothing catch