Repository navigation
Improve docker image publish and runtime upgrade test workflow #4744
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
Merged
mnaamani
merged 12 commits into
Joystream:master
from
mnaamani:joystream-node-docker-release
May 3, 2023
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
90cbc19
github workflows: factor out docker publish of joystream/node:latest …
mnaamani 30b96e5
devops: pull multi-arch images before creating manifest
mnaamani bfc8c61
runtime upgrade test: always pull base runtime
mnaamani a317f72
fix workflow syntax
mnaamani 8e8a2dc
runtime cache build use shasum tag instead of latest
mnaamani dca3b09
run runtime upgrade test - check runtimes before starting query-node
mnaamani 0a2e7d1
joystream-node docker fix build by picking older cargo-chef version
mnaamani 356b4e1
devops: playground deploy fix - drop install of deprecated aptitude
mnaamani d741a96
runtime upgrade ci tests: only run if there are code changes
mnaamani f12a839
don't run runtime-upgrade tests on master branch
mnaamani fd77ba3
Merge branch 'master' into joystream-node-docker-release
mnaamani f874a29
don't include bin in diff check for runtime upgrade tests
mnaamani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Publish production runtime build joystream/node:latest | ||
| name: joystream-node-docker-publish | ||
|
|
||
| on: | ||
| - workflow_dispatch | ||
|
|
||
| env: | ||
| REPOSITORY: joystream/node | ||
|
|
||
| jobs: | ||
| main: | ||
| name: Publish joystream/node:latest docker image | ||
| runs-on: ubuntu-latest | ||
| if: github.ref == 'refs/heads/master' | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: '14.x' | ||
|
|
||
| - id: compute_shasum | ||
| name: Compute runtime code shasum | ||
| run: | | ||
| export TAG_SHASUM=`scripts/runtime-code-shasum.sh` | ||
|
|
||
| - name: Login to DockerHub | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
|
||
| - name: Publish manifest | ||
| run: | | ||
| IMAGE=${{ env.REPOSITORY }}:${{ env.TAG_SHASUM }} | ||
| LATEST_TAG=${{ env.REPOSITORY }}:latest | ||
| docker pull $IMAGE-amd64 | ||
| docker pull $IMAGE-arm64 | ||
| docker manifest create $LATEST_TAG $IMAGE-amd64 $IMAGE-arm64 | ||
| docker manifest annotate $LATEST_TAG $IMAGE-amd64 --arch amd64 | ||
| docker manifest annotate $LATEST_TAG $IMAGE-arm64 --arch arm64 | ||
| docker manifest push $LATEST_TAG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ jobs: | |
| runs-on: ubuntu-latest | ||
| outputs: | ||
| use_artifact: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz | ||
| runtime: ${{ steps.compute_shasum.outputs.shasum }} | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/setup-node@v3 | ||
|
|
@@ -65,7 +66,7 @@ jobs: | |
| - name: Cache docker images | ||
| uses: actions/cache@v3 | ||
| env: | ||
| cache-name: joystream-node-docker | ||
| cache-name: joystream-node-docker-1 | ||
| with: | ||
| path: ~/docker-images | ||
| key: ${{ env.cache-name }}-${{ steps.compute_shasum.outputs.shasum }} | ||
|
|
@@ -83,8 +84,7 @@ jobs: | |
| run: | | ||
| if ! [ -f joystream-node-docker-image.tar.gz ]; then | ||
| docker pull joystream/node:${{ steps.compute_shasum.outputs.shasum }} | ||
| docker image tag joystream/node:${{ steps.compute_shasum.outputs.shasum }} joystream/node:latest | ||
| docker save --output joystream-node-docker-image.tar joystream/node:latest | ||
| docker save --output joystream-node-docker-image.tar joystream/node:${{ steps.compute_shasum.outputs.shasum }} | ||
| gzip joystream-node-docker-image.tar | ||
| cp joystream-node-docker-image.tar.gz ~/docker-images/ | ||
| fi | ||
|
|
@@ -117,7 +117,7 @@ jobs: | |
| CARGO_FEATURES=testing-runtime | ||
| CODE_SHASUM=${{ steps.compute_shasum.outputs.shasum }} | ||
| push: false | ||
| tags: joystream/node | ||
| tags: joystream/node:${{ steps.compute_shasum.outputs.shasum }} | ||
| cache-from: type=local,src=/tmp/.buildx-cache | ||
| cache-to: type=local,dest=/tmp/.buildx-cache | ||
| builder: ${{ steps.builder1.outputs.name }} | ||
|
|
@@ -126,7 +126,7 @@ jobs: | |
|
|
||
| - name: Save joystream/node image to cache | ||
| run: | | ||
| docker save --output joystream-node-docker-image.tar joystream/node | ||
| docker save --output joystream-node-docker-image.tar joystream/node:${{ steps.compute_shasum.outputs.shasum }} | ||
| gzip joystream-node-docker-image.tar | ||
| cp joystream-node-docker-image.tar.gz ~/docker-images/ | ||
| if: steps.check_files.outputs.files_exists == 'false' | ||
|
|
@@ -171,125 +171,74 @@ jobs: | |
| run: yarn workspace network-tests build | ||
| - name: Execute network tests | ||
| run: | | ||
| export RUNTIME=latest | ||
| export RUNTIME=${{ needs.build_images.outputs.runtime }} | ||
| export NO_STORAGE=${{ matrix.no_storage }} | ||
| tests/network-tests/run-tests.sh ${{ matrix.scenario }} | ||
|
|
||
| build_master_testing: | ||
| name: Build joystream node images for mainnet-testing | ||
| runtime_upgrade: | ||
| name: Runtime Upgrade from production runtime | ||
| needs: build_images | ||
| runs-on: ubuntu-latest | ||
| if: github.ref != 'refs/heads/master' | ||
| outputs: | ||
| use_artifact: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz | ||
| steps: | ||
| # Checkout master branch | ||
| - name: check out master repo | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| repository: Joystream/joystream | ||
| ref: master | ||
|
|
||
| - id: compute_shasum | ||
| - name: pull base runtime image | ||
| id: pull_base_image | ||
| env: | ||
| RUNTIME_PROFILE: 'TESTING' | ||
| run: | | ||
| export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh` | ||
| echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}" | ||
|
|
||
| - name: Setup cache directory | ||
| run: mkdir ~/docker-images | ||
|
|
||
| - name: Cache docker images | ||
| uses: actions/cache@v3 | ||
| env: | ||
| cache-name: joystream-node-docker-image-master | ||
| with: | ||
| path: ~/docker-images | ||
| key: ${{ env.cache-name }}-${{ steps.compute_shasum.outputs.shasum }} | ||
|
|
||
| - name: Check if we have cached image | ||
| continue-on-error: true | ||
| run: | | ||
| if [ -f ~/docker-images/joystream-node-docker-image-master.tar.gz ]; then | ||
| docker load --input ~/docker-images/joystream-node-docker-image-master.tar.gz | ||
| cp ~/docker-images/joystream-node-docker-image-master.tar.gz . | ||
| fi | ||
|
|
||
| - name: Check if we have pre-built image on Dockerhub | ||
| continue-on-error: true | ||
| run: | | ||
| if ! [ -f joystream-node-docker-image-master.tar.gz ]; then | ||
| docker pull joystream/node:${{ steps.compute_shasum.outputs.shasum }} | ||
| docker image tag joystream/node:${{ steps.compute_shasum.outputs.shasum }} joystream/node:mainnetDev | ||
| docker save --output joystream-node-docker-image-master.tar joystream/node:mainnetDev | ||
| gzip joystream-node-docker-image.tar | ||
| cp joystream-node-docker-image-master.tar.gz ~/docker-images/ | ||
| fi | ||
|
|
||
| - name: Check we now have an image | ||
| id: check_master_image | ||
| uses: andstor/file-existence-action@v1 | ||
| with: | ||
| files: 'joystream-node-docker-image-master.tar.gz' | ||
|
|
||
| - name: Set up Docker Buildx master | ||
| uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v1.7 | ||
| id: builder2 | ||
| if: steps.check_master_image.outputs.files_exists == 'false' | ||
| export RUNTIME=`scripts/runtime-code-shasum.sh` | ||
| echo "::set-output name=shasum::${RUNTIME}" | ||
| docker pull joystream/node:$RUNTIME | ||
| docker images | ||
|
|
||
| - name: Build master image | ||
| uses: docker/build-push-action@v3 | ||
| # Get new runtime built for this workflow (target runtime) | ||
| # tagged in local repo as joystream/node:latest | ||
| - name: Get artifacts | ||
| uses: actions/download-artifact@v3 | ||
| with: | ||
| context: . | ||
| file: joystream-node.Dockerfile | ||
| platforms: linux/amd64 | ||
| build-args: | | ||
| CARGO_FEATURES=testing-runtime | ||
| CODE_SHASUM=${{ steps.compute_shasum_master.outputs.shasum }} | ||
| push: false | ||
| tags: joystream/node:mainnetDev | ||
| builder: ${{ steps.builder2.outputs.name }} | ||
| load: true | ||
| if: steps.check_master_image.outputs.files_exists == 'false' | ||
|
|
||
| - name: Save joystream/node image to cache | ||
| name: ${{ needs.build_images.outputs.use_artifact }} | ||
| - name: Install artifacts | ||
| run: | | ||
| docker save --output joystream-node-docker-image-master.tar joystream/node:mainnetDev | ||
| gzip joystream-node-docker-image-master.tar | ||
| cp joystream-node-docker-image-master.tar.gz ~/docker-images/ | ||
| if: steps.check_master_image.outputs.files_exists == 'false' | ||
| docker load --input joystream-node-docker-image.tar.gz | ||
| docker images | ||
|
|
||
| - name: Save joystream/node image (master) to Artifacts | ||
| uses: actions/upload-artifact@v3 | ||
| # Checkout workflow's branch/tag/commit | ||
| - name: checkout workflow branch | ||
| uses: actions/checkout@v3 | ||
| - name: Check for runtime code changes | ||
| uses: technote-space/get-diff-action@v3 | ||
| with: | ||
| name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz | ||
| path: joystream-node-docker-image-master.tar.gz | ||
|
|
||
| runtime_upgrade: | ||
| name: Runtime Upgrade From production runtime | ||
| needs: [build_master_testing, build_images] | ||
| if: github.ref != 'refs/heads/master' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/setup-node@v3 | ||
| PREFIX_FILTER: | | ||
| runtime | ||
| runtime-modules | ||
| SUFFIX_FILTER: | | ||
| .rs | ||
| FILES: | | ||
| Cargo.lock | ||
| Cargo.toml | ||
| - name: setup node | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: '14.x' | ||
| - name: Install artifacts | ||
| uses: actions/download-artifact@v3 | ||
| - name: load docker images | ||
| run: | | ||
| docker load --input ${{needs.build_images.outputs.use_artifact}}/* | ||
| docker load --input ${{needs.build_master_testing.outputs.use_artifact}}/* | ||
| docker images | ||
| - name: Install packages and dependencies | ||
| if: env.GIT_DIFF | ||
| run: | | ||
| yarn build:packages | ||
| - name: Ensure tests are runnable | ||
| if: env.GIT_DIFF | ||
| run: yarn workspace network-tests build | ||
| - name: Execute network tests | ||
| if: env.GIT_DIFF | ||
| env: | ||
| RUNTIME: mainnetDev | ||
| TARGET_RUNTIME: latest | ||
| TARGET_RUNTIME: ${{ needs.build_images.outputs.runtime }} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job, this clearly needed to be adjusted |
||
| RUNTIME: ${{ steps.pull_base_image.outputs.shasum }} | ||
| run: | | ||
| export HOME=${PWD} | ||
| mkdir -p ${HOME}/.local/share/joystream-cli | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why there's a need for the -1 prefix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I just wanted to force github to use a new cache and not rely on previously cached artifacts