From ebdd8a1b1b2a7e2c699ece1bae07436c5993bbfd Mon Sep 17 00:00:00 2001 From: Bruce Collie Date: Fri, 7 Jun 2024 09:48:42 +0100 Subject: [PATCH 1/3] Set up K-style versioning --- .github/workflows/master.yml | 39 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 35 +++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/master.yml diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml new file mode 100644 index 0000000000..472938c8bc --- /dev/null +++ b/.github/workflows/master.yml @@ -0,0 +1,39 @@ +name: 'Bump version and make release job' +on: + push: + branches: + - 'master' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + version-bump: + name: 'Version Bump' + runs-on: ubuntu-latest + steps: + - name: 'Check out code' + uses: actions/checkout@v4 + with: + token: ${{ secrets.JENKINS_GITHUB_PAT }} + # fetch-depth 0 means deep clone the repo + fetch-depth: 0 + - name: 'Update Version' + run: | + set -x + git config user.name devops + git config user.email devops@runtimeverification.com + git checkout -B release origin/release + old_master="$(git merge-base origin/master origin/release)" + new_master="$(git rev-parse origin/master)" + if git diff --exit-code ${old_master} ${new_master} -- package/version; then + git merge --no-edit origin/master + ./package/version.sh bump + else + git merge --no-edit --strategy-option=theirs origin/master + fi + ./package/version.sh sub + if git add --update && git commit --no-edit --allow-empty --message "Set Version: $(cat package/version)"; then + git push origin release + fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb2cb0398a..1de841cd61 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: "Release" on: push: branches: - - master + - release env: ghc_version: "9.6.5" @@ -10,8 +10,27 @@ env: hpack_version: '0.36' jobs: + draft-release: + name: 'Draft Release' + runs-on: ubuntu-latest + steps: + - name: 'Check out code' + uses: actions/checkout@v4 + - name: 'Make release' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -x + VERSION=v$(cat package/version) + gh release create ${VERSION} \ + --repo runtimeverification/haskell-backend \ + --draft \ + --title ${VERSION} \ + --target ${{ github.sha }} + release: name: 'Release' + needs: draft-release runs-on: ubuntu-22.04 steps: - name: Check out code @@ -39,6 +58,7 @@ jobs: cache-cabal: name: 'Cache Cabal' + needs: draft-release strategy: fail-fast: false matrix: @@ -94,6 +114,7 @@ jobs: cache-stack: name: 'Cache Stack' runs-on: ubuntu-22.04 + needs: draft-release steps: - name: Install prerequisites run: | @@ -134,12 +155,22 @@ jobs: environment: production needs: [release, cache-cabal, cache-stack] steps: + - name: 'Finalise release' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -x + VERSION=v$(cat package/version) + gh release edit ${VERSION} \ + --repo runtimeverification/haskell-backend \ + --draft=false + - name: 'Update dependents' env: GITHUB_TOKEN: ${{ secrets.JENKINS_GITHUB_PAT }} run: | set -x - version="${GITHUB_SHA}" + version="$(cat package/version)" curl --fail \ -X POST \ -H "Accept: application/vnd.github+json" \ From ebb42f7903a2965bab14079a3072778198cd0e1f Mon Sep 17 00:00:00 2001 From: Bruce Collie Date: Fri, 7 Jun 2024 13:40:31 +0100 Subject: [PATCH 2/3] Bump versions in metadata --- booster/package.yaml | 2 +- dev-tools/package.yaml | 2 +- kore-rpc-types/kore-rpc-types.cabal | 2 +- kore/kore.cabal | 2 +- package/version.sh | 4 ++++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/booster/package.yaml b/booster/package.yaml index 33c731deab..c076b8038c 100644 --- a/booster/package.yaml +++ b/booster/package.yaml @@ -1,5 +1,5 @@ name: hs-backend-booster -version: '0.0.0' +version: '0.1.0' github: "runtimeverification/hs-backend-booster" license: BSD3 author: "Runtime Verification Inc" diff --git a/dev-tools/package.yaml b/dev-tools/package.yaml index fefd79d903..aea7fcccc1 100644 --- a/dev-tools/package.yaml +++ b/dev-tools/package.yaml @@ -1,5 +1,5 @@ name: hs-backend-booster-dev-tools -version: '0.0.0' +version: '0.1.0' github: "runtimeverification/hs-backend-booster" license: BSD3 author: "Runtime Verification Inc" diff --git a/kore-rpc-types/kore-rpc-types.cabal b/kore-rpc-types/kore-rpc-types.cabal index e74e7424c0..107f12e1bc 100644 --- a/kore-rpc-types/kore-rpc-types.cabal +++ b/kore-rpc-types/kore-rpc-types.cabal @@ -1,6 +1,6 @@ cabal-version: 2.2 name: kore-rpc-types -version: 0.60.0.0 +version: 0.1.0 description: Please see the [README](README.md) file. category: Language homepage: https://github.com/runtimeverification/haskell-backend#readme diff --git a/kore/kore.cabal b/kore/kore.cabal index 4aaad2650c..4037842519 100644 --- a/kore/kore.cabal +++ b/kore/kore.cabal @@ -1,6 +1,6 @@ cabal-version: 2.2 name: kore -version: 0.60.0.0 +version: 0.1.0 description: Please see the [README](README.md) file. category: Language homepage: https://github.com/runtimeverification/haskell-backend#readme diff --git a/package/version.sh b/package/version.sh index d0b41f721e..803499805f 100755 --- a/package/version.sh +++ b/package/version.sh @@ -28,6 +28,10 @@ version_bump() { version_sub() { local version version="$(cat $version_file)" + sed -i "s/^version: '.*'$/version: '${version}'/" dev-tools/package.yaml + sed -i "s/^version: '.*'$/version: '${version}'/" booster/package.yaml + sed -i "s/^version: .*$/version: ${version}/" kore/kore.cabal + sed -i "s/^version: .*$/version: ${version}/" ./kore-rpc-types/kore-rpc-types.cabal } version_command="$1" ; shift From 949ae714e0223e86773be33befc3242e098ea73d Mon Sep 17 00:00:00 2001 From: Bruce Collie Date: Mon, 10 Jun 2024 10:51:38 +0100 Subject: [PATCH 3/3] Move caching back to master --- .github/workflows/master.yml | 93 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 95 +---------------------------------- 2 files changed, 94 insertions(+), 94 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 472938c8bc..a986c9e68e 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -9,9 +9,102 @@ concurrency: jobs: + cache-cabal: + name: 'Cache Cabal' + strategy: + fail-fast: false + matrix: + include: + - runner: ubuntu-22.04 + os: ubuntu-22.04 + nix: x86_64-linux + - runner: MacM1 + os: self-macos-12 + nix: aarch64-darwin + runs-on: ${{ matrix.runner }} + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + submodules: recursive + + # Do the Following only on Public Runners; Mac Runner is pre-installed with build tools + - name: 'Install Nix' + if: ${{ !startsWith(matrix.os, 'self') }} + uses: cachix/install-nix-action@v25 + with: + install_url: https://releases.nixos.org/nix/nix-2.13.3/install + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + substituters = http://cache.nixos.org https://cache.iog.io + trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= + + - name: 'Install Cachix' + if: ${{ !startsWith(matrix.os, 'self') }} + uses: cachix/cachix-action@v14 + with: + name: k-framework + authToken: '${{ secrets.CACHIX_PUBLIC_TOKEN }}' + + - name: Cache Cabal package database and store + uses: actions/cache@v4 + with: + path: | + ~/.cabal/packages + ~/.cabal/store + key: cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('flake.lock') }}-${{ hashFiles('cabal.project') }}-${{ hashFiles('cabal.project.freeze') }}-${{ hashFiles('kore/kore.cabal') }}-${{ hashFiles('kore-rpc-types/kore-rpc-types.cabal') }}-${{ hashFiles('booster/hs-backend-booster.cabal') }} + restore-keys: | + cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('flake.lock') }}-${{ hashFiles('cabal.project') }}-${{ hashFiles('cabal.project.freeze') }}-${{ hashFiles('kore/kore.cabal') }}-${{ hashFiles('kore-rpc-types/kore-rpc-types.cabal') }} + cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('flake.lock') }}-${{ hashFiles('cabal.project') }}-${{ hashFiles('cabal.project.freeze') }}-${{ hashFiles('kore/kore.cabal') }} + cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('flake.lock') }}-${{ hashFiles('cabal.project') }}-${{ hashFiles('cabal.project.freeze') }} + cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('flake.lock') }}-${{ hashFiles('cabal.project') }} + cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('flake.lock') }} + + - name: Test + run: GC_DONT_GC=1 nix develop .#cabal --command bash -c "hpack ./booster && hpack dev-tools && cabal update && cabal build all && cabal test --enable-tests --test-show-details=direct kore-test unit-tests" + + cache-stack: + name: 'Cache Stack' + runs-on: ubuntu-22.04 + needs: draft-release + steps: + - name: Install prerequisites + run: | + sudo apt install --yes z3 libsecp256k1-dev + + - name: Check out code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Cache Stack root + uses: actions/cache@v4 + with: + path: ~/.stack + key: stack-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('stack.yaml') }}-${{ hashFiles('stack.yaml.lock') }} + restore-keys: | + stack-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('stack.yaml') }} + stack-${{ runner.os }}-ghc-${{ env.ghc_version }} + + - uses: haskell-actions/setup@v2.7 + id: setup-haskell-stack + with: + ghc-version: ${{ env.ghc_version }} + stack-version: ${{ env.stack_version }} + enable-stack: true + stack-setup-ghc: true + + - name: Build all + run: | + stack build --test --no-run-tests --pedantic + + - name: Run unit tests + run: stack test kore:kore-test hs-backend-booster:unit-tests + version-bump: name: 'Version Bump' runs-on: ubuntu-latest + needs: [cache-cabal, cache-stack] steps: - name: 'Check out code' uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1de841cd61..3ea482aae0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,104 +56,11 @@ jobs: - name: Build run: nix build .#kore-exec .#kore-rpc-booster - cache-cabal: - name: 'Cache Cabal' - needs: draft-release - strategy: - fail-fast: false - matrix: - include: - - runner: ubuntu-22.04 - os: ubuntu-22.04 - nix: x86_64-linux - - runner: MacM1 - os: self-macos-12 - nix: aarch64-darwin - runs-on: ${{ matrix.runner }} - steps: - - name: Check out code - uses: actions/checkout@v4 - with: - submodules: recursive - - # Do the Following only on Public Runners; Mac Runner is pre-installed with build tools - - name: 'Install Nix' - if: ${{ !startsWith(matrix.os, 'self') }} - uses: cachix/install-nix-action@v25 - with: - install_url: https://releases.nixos.org/nix/nix-2.13.3/install - extra_nix_config: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - substituters = http://cache.nixos.org https://cache.iog.io - trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= - - - name: 'Install Cachix' - if: ${{ !startsWith(matrix.os, 'self') }} - uses: cachix/cachix-action@v14 - with: - name: k-framework - authToken: '${{ secrets.CACHIX_PUBLIC_TOKEN }}' - - - name: Cache Cabal package database and store - uses: actions/cache@v4 - with: - path: | - ~/.cabal/packages - ~/.cabal/store - key: cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('flake.lock') }}-${{ hashFiles('cabal.project') }}-${{ hashFiles('cabal.project.freeze') }}-${{ hashFiles('kore/kore.cabal') }}-${{ hashFiles('kore-rpc-types/kore-rpc-types.cabal') }}-${{ hashFiles('booster/hs-backend-booster.cabal') }} - restore-keys: | - cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('flake.lock') }}-${{ hashFiles('cabal.project') }}-${{ hashFiles('cabal.project.freeze') }}-${{ hashFiles('kore/kore.cabal') }}-${{ hashFiles('kore-rpc-types/kore-rpc-types.cabal') }} - cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('flake.lock') }}-${{ hashFiles('cabal.project') }}-${{ hashFiles('cabal.project.freeze') }}-${{ hashFiles('kore/kore.cabal') }} - cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('flake.lock') }}-${{ hashFiles('cabal.project') }}-${{ hashFiles('cabal.project.freeze') }} - cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('flake.lock') }}-${{ hashFiles('cabal.project') }} - cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('flake.lock') }} - - - name: Test - run: GC_DONT_GC=1 nix develop .#cabal --command bash -c "hpack ./booster && hpack dev-tools && cabal update && cabal build all && cabal test --enable-tests --test-show-details=direct kore-test unit-tests" - - cache-stack: - name: 'Cache Stack' - runs-on: ubuntu-22.04 - needs: draft-release - steps: - - name: Install prerequisites - run: | - sudo apt install --yes z3 libsecp256k1-dev - - - name: Check out code - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Cache Stack root - uses: actions/cache@v4 - with: - path: ~/.stack - key: stack-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('stack.yaml') }}-${{ hashFiles('stack.yaml.lock') }} - restore-keys: | - stack-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('stack.yaml') }} - stack-${{ runner.os }}-ghc-${{ env.ghc_version }} - - - uses: haskell-actions/setup@v2.7 - id: setup-haskell-stack - with: - ghc-version: ${{ env.ghc_version }} - stack-version: ${{ env.stack_version }} - enable-stack: true - stack-setup-ghc: true - - - name: Build all - run: | - stack build --test --no-run-tests --pedantic - - - name: Run unit tests - run: stack test kore:kore-test hs-backend-booster:unit-tests - update-dependents: name: 'Publish Release' runs-on: ubuntu-latest environment: production - needs: [release, cache-cabal, cache-stack] + needs: release steps: - name: 'Finalise release' env: