From 7d33cc9f0a7ffeb18f8573fb18306241aeacd059 Mon Sep 17 00:00:00 2001 From: Kasper Peeters Date: Sun, 15 Dec 2024 17:51:26 +0000 Subject: [PATCH] Create homebrew package cadabra2-devel and run an automated test, on every commit. --- .github/workflows/homebrew-devel.yml | 66 ++++++++++++++++++++++++++++ .github/workflows/testbrew-devel.yml | 27 ++++++++++++ .github/workflows/testbrew.yml | 2 +- 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/homebrew-devel.yml create mode 100644 .github/workflows/testbrew-devel.yml diff --git a/.github/workflows/homebrew-devel.yml b/.github/workflows/homebrew-devel.yml new file mode 100644 index 0000000000..af25ac4170 --- /dev/null +++ b/.github/workflows/homebrew-devel.yml @@ -0,0 +1,66 @@ +# This is a build which gets triggered on every release, to +# update the homebrew-repo. + +name: Homebrew-devel + +# on: +# release: +# types: [released] + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout Cadabra + uses: actions/checkout@v4 + + - name: Checkout Homebrew repo + uses: actions/checkout@v4 + with: + repository: kpeeters/homebrew-repo + path: homebrew-repo + token: ${{ secrets.ACTIONS_HOMEBREW_REPO_TOKEN }} + + - name: Set up GitHub CLI + run: | + sudo apt-get update + sudo apt-get install -y gh + + - name: Authenticate GitHub CLI + run: gh auth setup-git + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get dependencies + run: sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get install git cmake jq python3-dev g++ libpcre3 libpcre3-dev libgmp3-dev libgtkmm-3.0-dev libboost-all-dev libgmp-dev libsqlite3-dev uuid-dev libmpfr-dev libmpc-dev && python3 --version && which python3 && python3 -m pip install --upgrade pip && python3 -m pip install wheel && python3 -m pip install sympy gmpy2 numpy + + - name: configure + run: git checkout devel && mkdir build && cd build && cmake -DPACKAGING_MODE=ON -DENABLE_MATHEMATICA=OFF -DCMAKE_INSTALL_PREFIX=/usr .. + + - name: Set variables + run: | + export VERSION=$(cat build/VERSION) + export COMMIT=$(curl -s https://api.github.com/repos/kpeeters/cadabra2/commits/devel | jq .sha) + wget https://github.com/kpeeters/cadabra2/archive/${COMMIT}.tar.gz + export SHA=`cat ${COMMIT}.tar.gz | sha256sum -b | cut -d " " -f 1` + echo "SHA=${SHA}" >> $GITHUB_ENV + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "COMMIT=$COMMIT" >> $GITHUB_ENV + + - name: Update Homebrew repo + run: | + cd homebrew-repo + cat cadabra2-devel.rb | sed -e 's/^ url .*/ url "https://github.com/kpeeters/cadabra2/archive/${COMMIT}.tar.gz"/' | sed -e 's/^ sha256.*/ sha256 "${{ env.SHA }}"/' > out.rb + mv out.rb cadabra2-devel.rb + cat cadabra2-devel.rb + git config user.name "Kasper Peeters" + git config user.email "info@cadabra.science" + git add cadabra2-devel.rb + git commit -a -m "Update to release ${{ env.VERSION }} commit ${{ env.COMMIT }}." + git push + + diff --git a/.github/workflows/testbrew-devel.yml b/.github/workflows/testbrew-devel.yml new file mode 100644 index 0000000000..b52166dedc --- /dev/null +++ b/.github/workflows/testbrew-devel.yml @@ -0,0 +1,27 @@ +# This is a build which gets triggered on every commit push, +# to test whether the homebrew package works. + +name: testbrew + +on: + workflow_run: + workflows: ["Homebrew-devel"] + types: + - completed + +jobs: + build: + + runs-on: macos-latest + + steps: + - uses: actions/checkout@v4 + + - name: get dependencies + run: brew tap kpeeters/repo && brew install cadabra2-devel + + - name: show + run: cat `which cadabra2` + + - name: test + run: echo "A+B;\nquit()\n" > tst.cdb && cadabra2 tst.cdb diff --git a/.github/workflows/testbrew.yml b/.github/workflows/testbrew.yml index 3f0dd5727f..5cfd83fac5 100644 --- a/.github/workflows/testbrew.yml +++ b/.github/workflows/testbrew.yml @@ -5,7 +5,7 @@ name: testbrew on: workflow_run: - workflows: ["homebrew"] + workflows: ["Homebrew"] types: - completed