diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd2eb2a4..9b827ccd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,7 @@ jobs: pos: [pos, no-pos] l3node: [l3node, l3node-token-6, no-l3node] tokenbridge: [tokenbridge, no-tokenbridge] + simple: [simple, no-simple] steps: - name: Checkout @@ -34,8 +35,8 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }} + key: ${{ runner.os }}-buildx-${{ hashFiles('**/Dockerfile') }} restore-keys: ${{ runner.os }}-buildx- - name: Startup Nitro testnode - run: ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ (matrix.l3node == 'l3node' && '--l3node') || (matrix.l3node == 'l3node-token-6' && '--l3node --l3-fee-token --l3-token-bridge --l3-fee-token-decimals 6') || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{ matrix.pos == 'pos' && '--pos' || '' }} + run: ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ (matrix.l3node == 'l3node' && '--l3node') || (matrix.l3node == 'l3node-token-6' && '--l3node --l3-fee-token --l3-token-bridge --l3-fee-token-decimals 6') || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --detach ${{ matrix.pos == 'pos' && '--pos' || '' }} --simple ${{ (matrix.simple == 'simple' && '--simple') || (matrix.simple == 'no-simple' && '--no-simple') || '' }} diff --git a/.github/workflows/testnode.bash b/.github/workflows/testnode.bash index be7e6961..63e5edf3 100755 --- a/.github/workflows/testnode.bash +++ b/.github/workflows/testnode.bash @@ -5,7 +5,7 @@ # Start the test node and get PID, to terminate it once send-l2 is done. cd ${GITHUB_WORKSPACE} -./test-node.bash "$@" +./test-node.bash "$@" --ci if [ $? -ne 0 ]; then echo "test-node.bash failed" diff --git a/docker-compose-ci-cache.json b/docker-compose-ci-cache.json new file mode 100644 index 00000000..0fee603d --- /dev/null +++ b/docker-compose-ci-cache.json @@ -0,0 +1,37 @@ +{ + "target": { + "scripts": { + "cache-from": [ + "type=local,src=/tmp/.buildx-cache" + ], + "cache-to": [ + "type=local,dest=/tmp/.buildx-cache,mode=max" + ], + "output": [ + "type=docker" + ] + }, + "rollupcreator": { + "cache-from": [ + "type=local,src=/tmp/.buildx-cache" + ], + "cache-to": [ + "type=local,dest=/tmp/.buildx-cache,mode=max" + ], + "output": [ + "type=docker" + ] + }, + "tokenbridge": { + "cache-from": [ + "type=local,src=/tmp/.buildx-cache" + ], + "cache-to": [ + "type=local,dest=/tmp/.buildx-cache,mode=max" + ], + "output": [ + "type=docker" + ] + } + } +} diff --git a/docker-compose.yaml b/docker-compose.yaml index f595b66a..22772f8a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -47,7 +47,7 @@ services: - "127.0.0.1:6379:6379" geth: - image: ethereum/client-go:latest + image: ethereum/client-go:stable ports: - "127.0.0.1:8545:8545" - "127.0.0.1:8551:8551" diff --git a/rollupcreator/Dockerfile b/rollupcreator/Dockerfile index f6406dad..13150b58 100644 --- a/rollupcreator/Dockerfile +++ b/rollupcreator/Dockerfile @@ -1,14 +1,14 @@ FROM node:18-bullseye-slim -ARG NITRO_CONTRACTS_BRANCH=main RUN apt-get update && \ - apt-get install -y git docker.io python3 build-essential curl jq + apt-get install -y git docker.io python3 make gcc g++ curl jq +ARG NITRO_CONTRACTS_BRANCH=main WORKDIR /workspace RUN git clone --no-checkout https://github.com/OffchainLabs/nitro-contracts.git ./ RUN git checkout ${NITRO_CONTRACTS_BRANCH} +RUN yarn install && yarn cache clean RUN curl -L https://foundry.paradigm.xyz | bash ENV PATH="${PATH}:/root/.foundry/bin" RUN foundryup RUN touch scripts/config.ts -RUN yarn install RUN yarn build:all ENTRYPOINT ["yarn"] diff --git a/test-node.bash b/test-node.bash index 9c7204cf..d0008b11 100755 --- a/test-node.bash +++ b/test-node.bash @@ -36,8 +36,10 @@ else fi run=true +ci=false validate=false detach=false +nowait=false blockscout=false tokenbridge=false l3node=false @@ -71,13 +73,13 @@ while [[ $# -gt 0 ]]; do read -p "are you sure? [y/n]" -n 1 response if [[ $response == "y" ]] || [[ $response == "Y" ]]; then force_init=true - build_utils=true - build_node_images=true echo else exit 0 fi fi + build_utils=true + build_node_images=true shift ;; --init-force) @@ -108,6 +110,10 @@ while [[ $# -gt 0 ]]; do done fi ;; + --ci) + ci=true + shift + ;; --build) build_dev_nitro=true build_dev_blockscout=true @@ -175,6 +181,14 @@ while [[ $# -gt 0 ]]; do detach=true shift ;; + --nowait) + if ! $detach; then + echo "Error: --nowait requires --detach to be provided." + exit 1 + fi + nowait=true + shift + ;; --batchposters) simple=false batchposters=$2 @@ -344,14 +358,21 @@ fi if $build_utils; then LOCAL_BUILD_NODES="scripts rollupcreator" - if $tokenbridge || $l3_token_bridge; then + # always build tokenbridge in CI mode to avoid caching issues + if $tokenbridge || $l3_token_bridge || $ci; then LOCAL_BUILD_NODES="$LOCAL_BUILD_NODES tokenbridge" fi - UTILS_NOCACHE="" - if $force_build_utils; then + + if [ "$ci" == true ]; then + # workaround to cache docker layers and keep using docker-compose in CI + docker buildx bake --file docker-compose.yaml --file docker-compose-ci-cache.json $LOCAL_BUILD_NODES + else + UTILS_NOCACHE="" + if $force_build_utils; then UTILS_NOCACHE="--no-cache" + fi + docker compose build --no-rm $UTILS_NOCACHE $LOCAL_BUILD_NODES fi - docker compose build --no-rm $UTILS_NOCACHE $LOCAL_BUILD_NODES fi if $dev_nitro; then @@ -371,7 +392,7 @@ if $blockscout; then fi if $build_node_images; then - docker compose build --no-rm $NODES scripts + docker compose build --no-rm $NODES fi if $force_init; then @@ -587,7 +608,11 @@ fi if $run; then UP_FLAG="" if $detach; then - UP_FLAG="--wait" + if $nowait; then + UP_FLAG="--detach" + else + UP_FLAG="--wait" + fi fi echo == Launching Sequencer diff --git a/tokenbridge/Dockerfile b/tokenbridge/Dockerfile index dac06fbb..4adce556 100644 --- a/tokenbridge/Dockerfile +++ b/tokenbridge/Dockerfile @@ -1,10 +1,12 @@ FROM node:18-bullseye-slim -ARG TOKEN_BRIDGE_BRANCH=main RUN apt-get update && \ - apt-get install -y git docker.io python3 build-essential + apt-get install -y git docker.io python3 make gcc g++ curl jq +ARG TOKEN_BRIDGE_BRANCH=main WORKDIR /workspace -RUN git clone --no-checkout https://github.com/OffchainLabs/token-bridge-contracts.git ./ -RUN git checkout ${TOKEN_BRIDGE_BRANCH} -RUN yarn install +RUN git clone --no-checkout https://github.com/OffchainLabs/token-bridge-contracts.git ./ && \ + git checkout ${TOKEN_BRIDGE_BRANCH} && \ + rm -rf .git && \ + git init && git add . && git -c user.name="user" -c user.email="user@example.com" commit -m "Initial commit" +RUN yarn install && yarn cache clean RUN yarn build ENTRYPOINT ["yarn"]