-
Notifications
You must be signed in to change notification settings - Fork 18
feat: add Docker support for running upgrade scripts #65
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
Changes from 6 commits
c750bda
1f0f4f3
eea7623
c5948fa
4c8edb8
9cb07c5
c445d7d
15b87cf
a8adfeb
4d391f9
c5520f7
c93b86f
92fbc31
e3addac
596182b
9dc0108
6dd231f
aaa6eea
ead0814
7977435
2f30dde
05c1282
80ab399
f083a68
5a4ceca
2acea4e
a863cdb
4b4712e
94bef28
3765422
54c190c
8344c39
707cc07
0efc403
657fd93
e7f8387
7a6d9a6
784b100
ede1c95
2853daa
d336a84
a022a65
1d77f3a
cb1cbeb
e4fed49
72497e2
38111b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Dependencies (will be installed fresh in container) | ||
| node_modules/ | ||
|
|
||
| # Build artifacts (will be built fresh in container) | ||
| out/ | ||
| cache_forge/ | ||
| cache/ | ||
| artifacts/ | ||
| typechain-types/ | ||
|
|
||
| # Environment files (contain secrets) | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Git | ||
| .git/ | ||
| .gitignore | ||
|
|
||
| # IDE | ||
| .vscode/ | ||
| .idea/ | ||
|
|
||
| # Test artifacts | ||
| broadcast/ | ||
| coverage/ | ||
|
|
||
| # Docker | ||
| Dockerfile | ||
| .dockerignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: Test Docker | ||
|
|
||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| test-docker: | ||
| name: Test Docker Image | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Foundry | ||
| uses: foundry-rs/foundry-toolchain@v1 | ||
| with: | ||
| version: stable | ||
|
|
||
| - name: Install forge dependencies | ||
| run: forge install | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build Docker image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| load: true | ||
| tags: orbit-actions:test | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| - name: Run Docker smoke tests | ||
| run: ./test/docker/test-docker.bash | ||
| env: | ||
| DOCKER_IMAGE: orbit-actions:test |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| node_modules | ||
| .env | ||
| .DS_Store | ||
|
|
||
| # Hardhat files | ||
| /cache | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||||
| FROM node:18-slim | ||||||||
|
|
||||||||
| # Install dependencies for Foundry and git | ||||||||
| RUN apt-get update && apt-get install -y \ | ||||||||
| curl \ | ||||||||
| git \ | ||||||||
| && rm -rf /var/lib/apt/lists/* | ||||||||
|
|
||||||||
| # Install Foundry | ||||||||
| RUN curl -L https://foundry.paradigm.xyz | bash | ||||||||
| ENV PATH="/root/.foundry/bin:${PATH}" | ||||||||
| RUN foundryup | ||||||||
|
|
||||||||
| # Install Yarn Classic (v1) - matches the repo's yarn.lock format | ||||||||
| RUN npm install -g --force yarn@1.22.22 | ||||||||
|
|
||||||||
| # Set working directory | ||||||||
| WORKDIR /app | ||||||||
|
|
||||||||
| # Copy package files first for better caching | ||||||||
| COPY package.json yarn.lock ./ | ||||||||
|
|
||||||||
| # Install dependencies (using --ignore-scripts like CI does, then forge install separately) | ||||||||
| RUN yarn install --frozen-lockfile --ignore-scripts | ||||||||
|
|
||||||||
| # Copy the rest of the repository | ||||||||
| COPY . . | ||||||||
|
||||||||
| COPY . . | |
| COPY . . | |
| RUN forge install |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| #!/bin/bash | ||
|
yahgwai marked this conversation as resolved.
|
||
| set -euo pipefail | ||
|
|
||
| # Docker smoke tests for orbit-actions | ||
| # Verifies that all required tools and scripts are accessible in the Docker image | ||
|
|
||
| IMAGE_NAME="${DOCKER_IMAGE:-orbit-actions:test}" | ||
|
|
||
| echo "=== Docker Smoke Tests ===" | ||
| echo "Image: $IMAGE_NAME" | ||
| echo "" | ||
|
|
||
| # Track failures | ||
| FAILURES=0 | ||
|
|
||
| run_test() { | ||
| local name="$1" | ||
| shift | ||
| echo -n "Testing $name... " | ||
| if "$@" > /dev/null 2>&1; then | ||
| echo "OK" | ||
| else | ||
| echo "FAILED" | ||
| FAILURES=$((FAILURES + 1)) | ||
| fi | ||
| } | ||
|
|
||
| # Test 1: Tools are installed | ||
| echo "--- Tool Availability ---" | ||
| run_test "forge" docker run --rm "$IMAGE_NAME" forge --version | ||
| run_test "cast" docker run --rm "$IMAGE_NAME" cast --version | ||
| run_test "yarn" docker run --rm "$IMAGE_NAME" yarn --version | ||
| run_test "node" docker run --rm "$IMAGE_NAME" node --version | ||
|
|
||
| # Test 2: Dependencies are installed | ||
| echo "" | ||
| echo "--- Dependencies ---" | ||
| run_test "node_modules exists" docker run --rm "$IMAGE_NAME" test -d node_modules | ||
| run_test "forge dependencies" docker run --rm "$IMAGE_NAME" test -d node_modules/@arbitrum | ||
|
|
||
| # Test 3: Contracts compile | ||
| echo "" | ||
| echo "--- Contract Compilation ---" | ||
| run_test "contracts built" docker run --rm "$IMAGE_NAME" test -d out | ||
|
|
||
| # Test 4: Scripts are accessible | ||
| echo "" | ||
| echo "--- Script Accessibility ---" | ||
|
|
||
| DEPLOY_SCRIPTS=( | ||
| "scripts/foundry/contract-upgrades/1.2.1/DeployNitroContracts1Point2Point1UpgradeAction.s.sol" | ||
| "scripts/foundry/contract-upgrades/2.1.0/DeployNitroContracts2Point1Point0UpgradeAction.s.sol" | ||
| "scripts/foundry/contract-upgrades/2.1.2/DeployNitroContracts2Point1Point2UpgradeAction.s.sol" | ||
| "scripts/foundry/contract-upgrades/2.1.3/DeployNitroContracts2Point1Point3UpgradeAction.s.sol" | ||
| "scripts/foundry/arbos-upgrades/at-timestamp/DeployUpgradeArbOSVersionAtTimestampAction.s.sol" | ||
| ) | ||
|
|
||
| for script in "${DEPLOY_SCRIPTS[@]}"; do | ||
| script_name=$(basename "$script") | ||
| run_test "$script_name exists" docker run --rm "$IMAGE_NAME" test -f "$script" | ||
| done | ||
|
|
||
| EXECUTE_SCRIPTS=( | ||
| "scripts/foundry/contract-upgrades/1.2.1/ExecuteNitroContracts1Point2Point1Upgrade.s.sol" | ||
| "scripts/foundry/contract-upgrades/2.1.0/ExecuteNitroContracts2Point1Point0Upgrade.s.sol" | ||
| "scripts/foundry/contract-upgrades/2.1.2/ExecuteNitroContracts2Point1Point2Upgrade.s.sol" | ||
| "scripts/foundry/contract-upgrades/2.1.3/ExecuteNitroContracts2Point1Point3Upgrade.s.sol" | ||
| ) | ||
|
|
||
| for script in "${EXECUTE_SCRIPTS[@]}"; do | ||
| script_name=$(basename "$script") | ||
| run_test "$script_name exists" docker run --rm "$IMAGE_NAME" test -f "$script" | ||
| done | ||
|
|
||
| # Test 5: Yarn scripts work | ||
| echo "" | ||
| echo "--- Yarn Scripts ---" | ||
| run_test "yarn orbit:contracts:version --help" docker run --rm "$IMAGE_NAME" yarn orbit:contracts:version --help | ||
|
yahgwai marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Test 6: Unit tests pass | ||
| echo "" | ||
| echo "--- Unit Tests ---" | ||
| echo "Running unit tests inside container..." | ||
| if docker run --rm "$IMAGE_NAME" yarn test:unit; then | ||
| echo "Unit tests: OK" | ||
| else | ||
| echo "Unit tests: FAILED" | ||
| FAILURES=$((FAILURES + 1)) | ||
| fi | ||
|
|
||
| # Summary | ||
| echo "" | ||
| echo "=== Summary ===" | ||
| if [ $FAILURES -eq 0 ]; then | ||
| echo "All tests passed!" | ||
| exit 0 | ||
| else | ||
| echo "$FAILURES test(s) failed" | ||
| exit 1 | ||
| fi | ||
Uh oh!
There was an error while loading. Please reload this page.