Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sub actions #11

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

> By convention please follow the release numbers from [Parity's repo](https://github.com/paritytech/try-runtime-cli).

1. Run the [prebuild github action](https://github.com/NodleCode/action-try-runtime/actions/workflows/base-image.yml) to pre-build `try-runtime`. Pass it the latest version from parity's repo (for example `v0.5.1`).
1. Run the [prebuild github action](https://github.com/NodleCode/action-try-runtime/actions/workflows/base-image.yml) to pre-build `try-runtime`. Pass it the latest version from parity's repo (for example `v0.6.1`).
2. Wait for the action to build succesfully, which will take a little while.
3. Update the first line in the action [`Dockerfile`](./Dockerfile) to use the version number of the new prebuilt container (in this example `v0.5.1`).
4. Draft a new github release for the same version number (`v0.5.1` in this example).
3. Update the first line in the action [`Dockerfile`](./Dockerfile) to use the version number of the new prebuilt container (in this example `v0.6.1`).
4. Draft a new github release for the same version number (`v0.6.1` in this example).
5. You may now use the newly release and built action in your CI/CD pipeline.

> We prebuild a docker container with `try-runtime` to ensure Github does not rebuilt `try-runtime` everytime we use this action, thus giving us a nice speed improvement.
Expand All @@ -23,19 +23,19 @@
Verify online version

```
docker run ghcr.io/nodlecode/try-runtime-cli:v0.5.1 try-runtime -V
docker run ghcr.io/nodlecode/try-runtime-cli:v0.6.1 try-runtime -V
```

Execute the prebuilt docker image

```
docker run -v ~/nodle/chain/snapshots:/snapshots ghcr.io/nodlecode/try-runtime-cli:v0.5.1 try-runtime --runtime ./snapshots/runtime_eden.wasm on-runtime-upgrade snap -p snapshots/eden-ci
docker run -v ~/nodle/chain/snapshots:/snapshots ghcr.io/nodlecode/try-runtime-cli:v0.6.1 try-runtime --runtime ./snapshots/runtime_eden.wasm on-runtime-upgrade snap -p snapshots/eden-ci
```

Build and run image locally
```
cd base
docker build --build-arg VERSION=v0.5.1 . -t milkman -f ./Dockerfile
docker build --build-arg VERSION=v0.6.1 . -t milkman -f ./Dockerfile

docker run milkman try-runtime --version
docker run milkman try-runtime --help
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/nodlecode/try-runtime-cli:v0.5.1
FROM ghcr.io/nodlecode/try-runtime-cli:v0.6.1

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ with:
### Use case with some more options
```yaml
- name: Run try-runtime
uses: NodleCode/action-try-runtime@v0.5.1
uses: NodleCode/action-try-runtime@v0.6.1
with:
url: 'https://rpc.nodleprotocol.io'
snap: snapshots/eden-snapshot-full
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ inputs:
description: 'Path to a previously taken snapshot, if does not exists we will create it'
default: '/tmp/default.snap'
runtime:
description: 'Path to a try-runtime enabled runtime to test migrations for'
description: 'Path to a try-runtime enabled runtime to test migrations for, Set to SKIP to skip test and only download snapshot'
required: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can change this to false if you want to make this option optional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a complication in how it is transferred to the Dockers' entrypoint with $1 $2 $3 $4

checks:
description: 'Checks to run'
Expand Down
6 changes: 6 additions & 0 deletions check/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ghcr.io/nodlecode/try-runtime-cli:v0.6.1

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]
27 changes: 27 additions & 0 deletions check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Try Runtime'
description: 'Runs try-runtime on-runtime-upgrade on the specified chain and runtime'
branding:
icon: 'check-circle'
color: 'green'
inputs:
snap:
description: 'Path to a previously taken snapshot'
default: '/tmp/default.snap'
runtime:
description: 'Path to a try-runtime enabled runtime to test migrations for'
required: true
checks:
description: 'Checks to run'
default: 'all'
options:
description: 'try-runtime command line options'
default: ''
required: false
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.snap }}
- ${{ inputs.runtime }}
- ${{ inputs.checks }}
- ${{ inputs.options }}
8 changes: 8 additions & 0 deletions check/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! /bin/sh -l

snap=$1
runtime=$2
checks=$3
shift 3

try-runtime --runtime $runtime on-runtime-upgrade --checks=$checks $* snap --path $snap
6 changes: 6 additions & 0 deletions create/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ghcr.io/nodlecode/try-runtime-cli:v0.6.1

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]
23 changes: 23 additions & 0 deletions create/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Try Runtime - create snapshot'
description: 'Runs try-runtime to create a snapshot'
branding:
icon: 'check-circle'
color: 'green'
inputs:
url:
description: 'URL of the node to take a snapshot from'
required: true
snap:
description: 'Path to a previously taken snapshot, if does not exists we will create it'
default: '/tmp/default.snap'
options:
description: "Other command line options"
required: false

runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.url }}
- ${{ inputs.snap }}
- ${{ inputs.options }}
7 changes: 7 additions & 0 deletions create/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/sh -l

url=$1
snap=$2
shift 2

try-runtime --runtime existing create-snapshot --uri $url $snap $*
4 changes: 3 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ if [ ! -f "$snap" ]; then
try-runtime --runtime existing create-snapshot --uri $url $snap
fi

try-runtime --runtime $runtime on-runtime-upgrade --checks=$checks $* snap --path $snap
if [ -f "$runtime" ];then
try-runtime --runtime $runtime on-runtime-upgrade --checks=$checks $* snap --path $snap
fi
Comment on lines +15 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this will do what you want since if runtime == SKIP this will still evaluate to true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check man [

then scroll down to;

       -f FILE
              FILE exists and is a regular file

Any non existing argument will skip