Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
chore(github): add evolve:state step to evolve action
Browse files Browse the repository at this point in the history
It accepts the source code TX ID you expect to run the evolveState function against. If they do not match, then the step will fail. This should help protect against uninteneded evolves and moves the reliance on local evolutions
  • Loading branch information
dtfiedler committed Nov 22, 2023
1 parent 1eb2e7a commit db51b38
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/evolve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: Build / Test / Evolve Contract

on:
workflow_dispatch:
inputs:
evolve-state-tx-id:
description: 'Confirm the source code transaction ID you are running evolve state against.'
required: false
type: string
default: null
push:
branches:
- develop
Expand Down Expand Up @@ -34,6 +40,10 @@ jobs:
environment: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
- run: yarn install
- run: yarn build
- id: evolve
Expand All @@ -46,3 +56,33 @@ jobs:
- run: |
git tag "${{ steps.evolve.outputs.srcTxId }}"
git push --tags
evolve-state:
if: github.event.inputs.evolve-state-tx-id != null
runs-on: ubuntu-latest
environment: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
- name: Validate Input
run: |
SOURCE_CODE_TX_ID=$(curl https://api.arns.app/v1/contract/${{ vars.ARNS_CONTRACT_TX_ID }} | jq -r '.state.evolve')
if [ -z "${{ github.event.inputs.evolve-state-tx-id }}" ]; then
echo "No evolve-state-tx-id provided. Exiting."
exit 1
fi
if [ "${{ github.event.inputs.evolve-state-tx-id }}" = "$SOURCE_CODE_TX_ID" ]; then
echo "The evolve-state-tx-id the current source code TX ID of the contract. Evolving state..."
else
echo "The evolve-state-tx-id does not match the current source code TX ID of the contract. Exiting."
exit 1
fi
- run: yarn install
- run: yarn evolve:state
env:
ARNS_CONTRACT_TX_ID: ${{ vars.ARNS_CONTRACT_TX_ID }}
JWK: ${{ secrets.JWK }}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test:integration": "yarn build && jest --testPathPattern=tests --globalSetup=./tests/setup.jest.ts --globalTeardown=./tests/teardown.jest.ts --runInBand",
"test": "yarn build && yarn test:unit ; yarn test:integration",
"evolve": "yarn ts-node ./tools/evolve-contract.ts",
"evolve:state": "yarn ts-node ./tools/evolve-state.ts",
"tick": "yarn ts-node ./tools/tick.ts",
"prepare": "husky install",
"pre-commit": "lint-staged"
Expand Down

0 comments on commit db51b38

Please sign in to comment.