ci compatibility with M1 chips #176
Workflow file for this run
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
| name: Elixir CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| jobs: | |
| unit_test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| elixir-version: [1.16, 1.17, 1.18] | |
| otp-version: [25.0, 26.0] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Elixir | |
| uses: erlef/setup-beam@v1 | |
| with: | |
| elixir-version: ${{ matrix.elixir-version }} | |
| otp-version: ${{ matrix.otp-version }} | |
| - name: Cache dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: deps | |
| key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Run tests | |
| run: mix test --warnings-as-errors | |
| integration_test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| elixir-version: [1.18] | |
| otp-version: [26.0] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20.8.0" | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y netcat-openbsd socat | |
| # Detect architecture | |
| ARCH=$(dpkg --print-architecture) | |
| echo "Detected architecture: $ARCH" | |
| if [ "$ARCH" = "amd64" ]; then | |
| # Download and install libssl1.1 manually for x86_64 | |
| wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb | |
| sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb || true | |
| sudo apt-get install -f -y | |
| elif [ "$ARCH" = "arm64" ]; then | |
| # For ARM64 (e.g., running with act on Apple Silicon), install x86_64 compatibility | |
| echo "Installing x86_64 compatibility libraries for ARM64" | |
| # Add amd64 architecture support | |
| sudo dpkg --add-architecture amd64 | |
| # Handle traditional sources.list format | |
| if [ -f /etc/apt/sources.list ]; then | |
| sudo sed -i 's/^deb /deb [arch=arm64] /' /etc/apt/sources.list | |
| sudo sed -i 's/^deb-src /deb-src [arch=arm64] /' /etc/apt/sources.list | |
| fi | |
| # Handle DEB822 format (.sources files) used by Ubuntu 24.04+ | |
| # These files use "Architectures:" field instead of inline [arch=] | |
| for f in /etc/apt/sources.list.d/*.sources; do | |
| if [ -f "$f" ]; then | |
| echo "Restricting $f to arm64 architecture" | |
| # Add "Architectures: arm64" after the "Types:" line if not already present | |
| if ! grep -q "^Architectures:" "$f"; then | |
| sudo sed -i '/^Types:/a Architectures: arm64' "$f" | |
| fi | |
| fi | |
| done | |
| # Also fix traditional .list files that might reference ports.ubuntu.com | |
| for f in /etc/apt/sources.list.d/*.list; do | |
| if [ -f "$f" ] && grep -q "ports.ubuntu.com" "$f"; then | |
| sudo sed -i 's/^deb /deb [arch=arm64] /' "$f" | |
| sudo sed -i 's/^deb-src /deb-src [arch=arm64] /' "$f" | |
| fi | |
| done | |
| # Add amd64 package sources from archive.ubuntu.com (has amd64 packages) | |
| # Use noble (24.04) to match the container's Ubuntu version | |
| echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ noble main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/amd64.list | |
| echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ noble-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/amd64.list | |
| sudo apt-get update | |
| # Install x86_64 libraries needed to run x86_64 binaries | |
| sudo apt-get install -y libc6:amd64 libstdc++6:amd64 zlib1g:amd64 libgmp10:amd64 | |
| # Download and install libssl1.1 for amd64 (from focal/20.04 since noble doesn't have it) | |
| wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb | |
| sudo dpkg --force-architecture -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb || true | |
| sudo apt-get install -f -y | |
| # Also install libssl1.1 for arm64 (needed by Erlang's crypto library) | |
| wget http://ports.ubuntu.com/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_arm64.deb | |
| sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_arm64.deb || true | |
| sudo apt-get install -f -y | |
| fi | |
| - name: Cache Cardano CLI and Address | |
| uses: actions/cache@v3 | |
| id: cardano-cache | |
| with: | |
| path: | | |
| ~/.cache/cardano-cli | |
| /usr/local/bin/cardano-cli | |
| /usr/local/bin/cardano-node | |
| /usr/local/bin/cardano-address | |
| key: ${{ runner.os }}-${{ runner.arch }}-cardano-tools-10.2.1 | |
| restore-keys: | | |
| ${{ runner.os }}-${{ runner.arch }}-cardano-tools- | |
| - name: Install Cardano Tools | |
| if: steps.cardano-cache.outputs.cache-hit != 'true' | |
| run: | | |
| # Install dependencies | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev libsodium-dev zlib1g-dev make g++ jq libncursesw6 libtinfo6 | |
| # Create cache directory | |
| mkdir -p ~/.cache/cardano-cli | |
| # Download and install cardano-cli | |
| wget https://github.com/IntersectMBO/cardano-node/releases/download/10.2.1/cardano-node-10.2.1-linux.tar.gz -O ~/.cache/cardano-cli/cardano-node_10.2.1_linux.tar.gz | |
| # Extract with verbose output to see the structure | |
| tar -tvf ~/.cache/cardano-cli/cardano-node_10.2.1_linux.tar.gz | |
| # Extract the tar file | |
| tar -xzf ~/.cache/cardano-cli/cardano-node_10.2.1_linux.tar.gz -C ~/.cache/cardano-cli | |
| # Download and install cardano-address | |
| wget https://github.com/IntersectMBO/cardano-addresses/releases/download/4.0.0/cardano-address-4.0.0-linux.tar.gz -O ~/.cache/cardano-cli/cardano-addresses.tar.gz | |
| tar -xzf ~/.cache/cardano-cli/cardano-addresses.tar.gz -C ~/.cache/cardano-cli | |
| # List the contents to verify | |
| echo "Contents of cache directory:" | |
| ls -la ~/.cache/cardano-cli | |
| # Find the executables | |
| CARDANO_CLI_PATH=$(find ~/.cache/cardano-cli -name "cardano-cli" -type f | head -n 1) | |
| CARDANO_NODE_PATH=$(find ~/.cache/cardano-cli -name "cardano-node" -type f | head -n 1) | |
| CARDANO_ADDR_PATH=$(find ~/.cache/cardano-cli -name "cardano-address" -type f | head -n 1) | |
| if [ -z "$CARDANO_CLI_PATH" ] || [ -z "$CARDANO_NODE_PATH" ] || [ -z "$CARDANO_ADDR_PATH" ]; then | |
| echo "Could not find one or more required executables" | |
| find ~/.cache/cardano-cli -type f | |
| exit 1 | |
| fi | |
| echo "Found cardano-cli at: $CARDANO_CLI_PATH" | |
| echo "Found cardano-node at: $CARDANO_NODE_PATH" | |
| echo "Found cardano-address at: $CARDANO_ADDR_PATH" | |
| # Install to system | |
| sudo cp "$CARDANO_CLI_PATH" /usr/local/bin/cardano-cli | |
| sudo cp "$CARDANO_NODE_PATH" /usr/local/bin/cardano-node | |
| sudo cp "$CARDANO_ADDR_PATH" /usr/local/bin/cardano-address | |
| # Make them executable | |
| sudo chmod +x /usr/local/bin/cardano-cli | |
| sudo chmod +x /usr/local/bin/cardano-node | |
| sudo chmod +x /usr/local/bin/cardano-address | |
| # Verify installation | |
| cardano-cli --version | |
| cardano-address --version | |
| # Add to PATH for the current session | |
| echo "$(dirname "$CARDANO_CLI_PATH")" >> $GITHUB_PATH | |
| - name: Cache Yaci DevKit | |
| uses: actions/cache@v3 | |
| id: yaci-cache | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-yaci-devkit-${{ hashFiles('package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yaci-devkit- | |
| - name: Cache Yaci Components | |
| uses: actions/cache@v3 | |
| id: yaci-components-cache | |
| with: | |
| path: ~/.yaci-components | |
| key: ${{ runner.os }}-yaci-components-0.2.0 | |
| restore-keys: | | |
| ${{ runner.os }}-yaci-components- | |
| - name: Install Yaci DevKit | |
| run: npm install -g @bloxbean/yaci-devkit | |
| - name: Start Yaci DevKit in background | |
| run: | | |
| # Kill any existing Yaci DevKit processes | |
| pkill -f yaci-devkit || true | |
| # Start Yaci DevKit with verbose output and use pre-downloaded components | |
| # Defaults to emitting blocks in conway era format, which is the only | |
| # era currently supported by Xander. | |
| nohup yaci-devkit up > yaci-devkit.log 2>&1 & | |
| # Save the process ID | |
| echo $! > yaci-devkit.pid | |
| # Display the log file for debugging | |
| tail -f yaci-devkit.log & | |
| TAIL_PID=$! | |
| # Wait for the log to show that Yaci DevKit is starting | |
| for i in {1..10}; do | |
| if grep -q "Starting Yaci DevKit" yaci-devkit.log; then | |
| echo "Yaci DevKit is starting..." | |
| break | |
| fi | |
| echo "Waiting for Yaci DevKit to start in logs..." | |
| sleep 2 | |
| done | |
| # Kill the tail process | |
| kill $TAIL_PID || true | |
| - name: Wait for Yaci DevKit to start | |
| run: | | |
| # Check if the process is still running | |
| if ! ps -p $(cat yaci-devkit.pid) > /dev/null; then | |
| echo "Yaci DevKit process died. Log contents:" | |
| cat yaci-devkit.log | |
| exit 1 | |
| fi | |
| # Wait for the Cardano node socket to be available | |
| for i in {1..60}; do | |
| # Extract the socket path from the Yaci DevKit logs | |
| YACI_SOCKET_PATH=$(grep -o "$HOME/.yaci-cli/local-clusters/default/node/node.sock" yaci-devkit.log || echo "") | |
| if [ -z "$YACI_SOCKET_PATH" ]; then | |
| echo "Could not find socket path in Yaci DevKit logs. Using default path." | |
| YACI_SOCKET_PATH="$HOME/.yaci-cli/local-clusters/default/node/node.sock" | |
| fi | |
| # Check if the socket file exists | |
| if [ -S "$YACI_SOCKET_PATH" ]; then | |
| echo "Yaci DevKit Cardano node socket is up!" | |
| echo "CARDANO_NODE_SOCKET_PATH=$YACI_SOCKET_PATH" >> $GITHUB_ENV | |
| exit 0 | |
| fi | |
| echo "Waiting for Yaci DevKit Cardano node socket to start... (attempt $i/60)" | |
| sleep 5 | |
| done | |
| echo "Yaci DevKit failed to start. Log contents:" | |
| cat yaci-devkit.log | |
| exit 1 | |
| - name: Set up Elixir | |
| uses: erlef/setup-beam@v1 | |
| with: | |
| elixir-version: ${{ matrix.elixir-version }} | |
| otp-version: ${{ matrix.otp-version }} | |
| - name: Cache dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: deps | |
| key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Run integration tests | |
| run: mix test --include integration --warnings-as-errors | |
| env: | |
| CARDANO_NODE_SOCKET_PATH: ${{ env.CARDANO_NODE_SOCKET_PATH }} |