From ba1d50d120f03a83f6afadd1863638a36e18c262 Mon Sep 17 00:00:00 2001 From: nHackel Date: Fri, 8 Nov 2024 09:36:31 +0100 Subject: [PATCH] Add breakage CI --- .github/workflows/Breakage.yml | 76 ++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/Breakage.yml diff --git a/.github/workflows/Breakage.yml b/.github/workflows/Breakage.yml new file mode 100644 index 0000000..a96586d --- /dev/null +++ b/.github/workflows/Breakage.yml @@ -0,0 +1,76 @@ +name: Breakage +# Based on: https://github.com/JuliaSmoothOptimizers/LinearOperators.jl/blob/main/.github/workflows/Breakage.yml +on: + pull_request: + branches: + - master + types: [opened, reopened, labeled, synchronize] + + +jobs: + break: + if: ${{ contains(github.event.pull_request.labels.*.name, 'breakage') }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + pkg: [ + "MagneticParticleImaging/MPIReco.jl", + ] + pkgversion: [latest, stable] + + steps: + - uses: actions/checkout@v4 + + # Install Julia + - uses: julia-actions/setup-julia@v2 + with: + version: 1 + arch: x64 + - uses: actions/cache@v4 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@v1 + + # Breakage test + - name: 'Breakage of ${{ matrix.pkg }}, ${{ matrix.pkgversion }} version' + env: + URL: ${{ matrix.pkg }} + VERSION: ${{ matrix.pkgversion }} + run: | + set -v + mkdir -p ./pr + echo "${{ github.event.number }}" > ./pr/NR + git clone https://github.com/$URL + export PKG=$(echo $URL | cut -f2 -d/) + cd $PKG + if [ $VERSION == "stable" ]; then + TAG=$(git tag -l "v*" --sort=-creatordate | head -n1) + if [ -z "$TAG" ]; then + TAG="no_tag" + else + git checkout $TAG + fi + else + TAG=$VERSION + fi + export TAG + julia -e 'using Pkg; + PKG, TAG, VERSION = ENV["PKG"], ENV["TAG"], ENV["VERSION"] + joburl = joinpath(ENV["GITHUB_SERVER_URL"], ENV["GITHUB_REPOSITORY"], "actions/runs", ENV["GITHUB_RUN_ID"]) + TAG == "no_tag" && error("Not tag for $VERSION") + pkg"activate ."; + pkg"instantiate"; + pkg"dev ../"; + if TAG == "latest" + global TAG = chomp(read(`git rev-parse --short HEAD`, String)) + end + pkg"build"; + pkg"test";' \ No newline at end of file