Skip to content

Commit

Permalink
feat: cache build images
Browse files Browse the repository at this point in the history
  • Loading branch information
ratik committed Feb 9, 2024
1 parent 19dfec4 commit 7276629
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 17 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,18 @@ jobs:
with:
go-version: 1.20
cache: false
- name: Lint
run: cd integration_tests && yarn --ignore-engines && yarn lint
# - name: Build images
# run: |
# cd integration_tests
# cat package.json | grep -e "build-[a-z]*-image\"" | awk -F: '{print $1}' | tr -d ' ",{}' | xargs -I % -P 3 yarn %
- uses: jpribyl/[email protected]
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
with:
key: docker-layer-caching-lido
restore-keys: docker-layer-caching-lido
- name: Build images
run: |
cd integration_tests
yarn build-images
- name: Lint
run: cd integration_tests && yarn --ignore-engines && yarn lint
- run: make compile
- name: Run tests
run: |
Expand Down
13 changes: 13 additions & 0 deletions integration_tests/dockerfiles/build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
VERSION=$(cat ./package.json | jq -r '.version')
cd dockerfiles
IMAGES=$(ls -1 | grep -v build-all.sh)
for IMAGE in $IMAGES; do
# check if docker image is already built
if [[ "$(docker images -q $IMAGE-test:$VERSION 2> /dev/null)" == "" ]]; then
echo "Building $IMAGE:$VERSION"
./$IMAGE/build.sh
else
echo "Image $IMAGE:$VERSION already exists"
fi
done
3 changes: 2 additions & 1 deletion integration_tests/dockerfiles/gaia/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
DIR="$(dirname $0)"
cd $DIR
VERSION=$(cat ../../package.json | jq -r '.version')
git clone https://github.com/cosmos/gaia.git -b v14.1.0
cp ./Dockerfile ./gaia
docker build gaia -t gaia
docker build gaia -t gaia-test:$VERSION
rm -rf ./gaia
6 changes: 6 additions & 0 deletions integration_tests/dockerfiles/hermes/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
DIR="$(dirname $0)"
cd $DIR
VERSION=$(cat ../../package.json | jq -r '.version')
docker build . -t hermes-test:$VERSION

3 changes: 2 additions & 1 deletion integration_tests/dockerfiles/lsm/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
DIR="$(dirname $0)"
cd $DIR
VERSION=$(cat ../../package.json | jq -r '.version')
git clone https://github.com/iqlusioninc/liquidity-staking-module -b sam/simapp-enable-ibc
cp ./Dockerfile ./liquidity-staking-module
docker build liquidity-staking-module -t lsm
docker build liquidity-staking-module -t lsm-test:$VERSION
rm -rf ./liquidity-staking-module
6 changes: 5 additions & 1 deletion integration_tests/dockerfiles/neutron-query-relayer/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
DIR="$(dirname $0)"
cd $DIR
git clone https://github.com/neutron-org/neutron-query-relayer
VERSION=$(cat ../../package.json | jq -r '.version')
cd neutron-query-relayer
make build-docker
GVERSION=$(echo $(git describe --tags) | sed 's/^v//')
COMMIT=$(git log -1 --format='%H')
ldflags="-X github.com/neutron-org/neutron-query-relayer/internal/app.Version=$VERSION -X github.com/neutron-org/neutron-query-relayer/internal/app.Commit=$COMMIT"
docker build --build-arg LDFLAGS="$ldflags" . -t neutron-query-relayer-test:$VERSION
cd ..
rm -rf ./neutron-query-relayer
3 changes: 2 additions & 1 deletion integration_tests/dockerfiles/neutron/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
DIR="$(dirname $0)"
COMMIT_HASH_OR_BRANCH="main"
cd $DIR
VERSION=$(cat ../../package.json | jq -r '.version')
git clone https://github.com/neutron-org/neutron
cd neutron
git checkout $COMMIT_HASH_OR_BRANCH
make build-docker-image
docker buildx build --load --build-context app=. -t neutron-test:$VERSION --build-arg BINARY=neutrond .
cd ..
rm -rf ./neutron
4 changes: 2 additions & 2 deletions integration_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"build-ts-client": "ts-node ./src/rebuild-client.ts",
"build-lsm-image": "./dockerfiles/lsm/build.sh",
"build-gaia-image": "./dockerfiles/gaia/build.sh",
"build-hermes-image": "docker build ./dockerfiles/hermes -t hermes",
"build-hermes-image": "./dockerfiles/hermes/build.sh",
"build-neutron-image": "./dockerfiles/neutron/build.sh",
"build-neutron-query-relayer-image": "./dockerfiles/neutron-query-relayer/build.sh",
"build-images": "yarn build-lsm-image && yarn build-gaia-image && yarn build-hermes-image && yarn build-neutron-image && yarn build-neutron-query-relayer-image",
"build-images": "./dockerfiles/build-all.sh && docker images",
"lint": "eslint ./src -f compact"
},
"dependencies": {
Expand Down
11 changes: 6 additions & 5 deletions integration_tests/src/testSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Client as NeutronClient } from '@neutron-org/client-ts';
import { waitFor } from './helpers/waitFor';
import { sleep } from './helpers/sleep';
import child_process from 'child_process';
const packageJSON = require(`${__dirname}/../package.json`);

const keys = [
'master',
Expand All @@ -24,7 +25,7 @@ const networkConfigs = {
binary: 'liquidstakingd',
chain_id: 'testlsm',
denom: 'stake',
image: 'lsm',
image: `lsm-test:${packageJSON.version}`,
prefix: 'cosmos',
trace: true,
validators: 2,
Expand Down Expand Up @@ -56,7 +57,7 @@ const networkConfigs = {
binary: 'gaiad',
chain_id: 'testgaia',
denom: 'stake',
image: 'gaia',
image: `gaia-test:${packageJSON.version}`,
prefix: 'cosmos',
trace: true,
validators: 2,
Expand Down Expand Up @@ -91,7 +92,7 @@ const networkConfigs = {
binary: 'neutrond',
chain_id: 'ntrntest',
denom: 'untrn',
image: 'neutron-node',
image: `neutron-test:${packageJSON.version}`,
prefix: 'neutron',
loglevel: 'debug',
trace: true,
Expand Down Expand Up @@ -133,14 +134,14 @@ const relayersConfig = {
'chains.1.gas_multiplier': 1.2,
'chains.0.gas_multiplier': 1.2,
},
image: 'hermes',
image: `hermes-test:${packageJSON.version}`,
log_level: 'trace',
type: 'hermes',
},
neutron: {
balance: '1000000000',
binary: 'neutron-query-relayer',
image: 'neutron-org/neutron-query-relayer',
image: `neutron-query-relayer-test:${packageJSON.version}`,
log_level: 'debug',
type: 'neutron',
},
Expand Down

0 comments on commit 7276629

Please sign in to comment.