From efc4153aee19b3e2671a91bdec93e1900489a941 Mon Sep 17 00:00:00 2001 From: ajimeno04 Date: Tue, 13 Aug 2024 09:09:33 +0200 Subject: [PATCH] Chore: Add DockerFile for github actions --- deployments/ci/Dockerfile.tests | 43 +++++++++++++++++++++++++++++++ deployments/ci/install_foundry.sh | 25 ++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 deployments/ci/Dockerfile.tests create mode 100755 deployments/ci/install_foundry.sh diff --git a/deployments/ci/Dockerfile.tests b/deployments/ci/Dockerfile.tests new file mode 100644 index 0000000..12a1450 --- /dev/null +++ b/deployments/ci/Dockerfile.tests @@ -0,0 +1,43 @@ +# Dockerfile.tests located in deployments/ci + +# Use the official Node.js image as a base +FROM node:21.7.1 + +# Install curl and other necessary tools +RUN apt-get update && apt-get install -y curl sudo + +# Set the working directory inside the Docker container +WORKDIR /usr/src/app + +# Copy the ABIs directory first to ensure it's available during installation +COPY ./abis ./abis + +# Copy package.json and pnpm-lock.yaml for dependency installation +COPY package.json pnpm-lock.yaml ./ + +# Install pnpm globally +RUN npm install -g pnpm + +# Install app dependencies (including running the postinstall script) +RUN pnpm install --no-frozen-lockfile + +# Copy the rest of the application code +COPY . . + +# Ensure the install_foundry.sh script is executable +RUN chmod +x ./deployments/ci/install_foundry.sh + +# Run the Foundry and anvil installation script +RUN ./deployments/ci/install_foundry.sh + +# Add Foundry binaries to the PATH +ENV PATH="/root/.foundry/bin:$PATH" + +# Verify that `anvil` is correctly installed and accessible +RUN anvil --version + +# Run any additional setup scripts if needed +RUN pnpm before-test # This might be where Typechain commands are executed + +# Default command to run the tests +CMD ["pnpm", "test"] diff --git a/deployments/ci/install_foundry.sh b/deployments/ci/install_foundry.sh new file mode 100755 index 0000000..31cd1d8 --- /dev/null +++ b/deployments/ci/install_foundry.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# Install Foundry and anvil +echo "Installing Foundry and anvil" +curl -L https://foundry.paradigm.xyz | bash + +echo "Reloading the shell configuration to update PATH" +if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" +elif [ -f "$HOME/.profile" ]; then + . "$HOME/.profile" +elif [ -f "$HOME/.zshrc" ]; then + . "$HOME/.zshrc" +fi + +echo "Verifying Foundry installation" +if command -v foundryup >/dev/null 2>&1; then + echo "Foundry installed successfully!" + source /home/runner/.bashrc + foundryup --version + foundryup +else + echo "Foundry installation failed. foundryup command not found." + exit 1 +fi