Bump actions/download-artifact from 5 to 6 (#1216) #4181
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
| # Copyright (C) 2023 Toitware ApS. All rights reserved. | |
| name: CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - "*" | |
| - "*/*" | |
| env: | |
| SUPABASE_VERSION: 1.187.10 | |
| EXCLUDED_SUPABASE_SERVICES: imgproxy,inbucket,pgadmin-schema-diff,migra,studio,deno-relay | |
| # Qemu release page: https://github.com/espressif/qemu/releases/tag/esp-develop-8.2.0-20240122 | |
| QEMU_LINUX_URL: https://github.com/espressif/qemu/releases/download/esp-develop-8.2.0-20240122/qemu-xtensa-softmmu-esp_develop_8.2.0_20240122-x86_64-linux-gnu.tar.xz | |
| QEMU_MACOS_URL: https://github.com/espressif/qemu/releases/download/esp-develop-8.2.0-20240122/qemu-xtensa-softmmu-esp_develop_8.2.0_20240122-aarch64-apple-darwin.tar.xz | |
| QEMU_WINDOWS_URL: https://github.com/espressif/qemu/releases/download/esp-develop-8.2.0-20240122/qemu-xtensa-softmmu-esp_develop_8.2.0_20240122-x86_64-w64-mingw32.tar.xz | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [ ubuntu-latest, macos-latest, windows-latest ] | |
| run_supabase_tests: [ false ] | |
| include: | |
| - os: ubuntu-latest | |
| run_supabase_tests: true | |
| - os: ubuntu-latest | |
| run_supabase_tests: false | |
| upload-service: true | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| submodules: true | |
| # We have a test that wants to tag a specific commit. | |
| # As such we need to fetch all history. | |
| fetch-depth: 0 | |
| - name: Setup environment variables and Toit version | |
| id: constants | |
| shell: bash | |
| run: | | |
| if [[ "$RUNNER_OS" = "Windows" ]]; then | |
| BIN_EXTENSION=".exe" | |
| fi | |
| echo "BIN_EXTENSION=$BIN_EXTENSION" >> $GITHUB_ENV | |
| export TOIT_VERSION=$(make dev-sdk-version) | |
| echo "toitVersion=$TOIT_VERSION" >> $GITHUB_OUTPUT | |
| # For upload at the end. | |
| # We only upload for Linux and macOS. | |
| echo "SNAPSHOTS_DIR=$HOME/.cache/jaguar/snapshots" >> $GITHUB_ENV | |
| - uses: toitlang/action-setup@v1 | |
| with: | |
| toit-version: ${{ steps.constants.outputs.toitVersion }} | |
| - name: Setup Qemu | |
| shell: bash | |
| run: | | |
| mkdir -p downloads | |
| cd downloads | |
| if [[ ${{ runner.os }} == "Linux" ]]; then | |
| curl -L -o qemu-linux.tar.xz $QEMU_LINUX_URL | |
| tar x -f qemu-linux.tar.xz | |
| echo "QEMU_EXEC=$PWD/qemu/bin/qemu-system-xtensa" >> $GITHUB_ENV | |
| elif [[ ${{ runner.os }} == "macOS" ]]; then | |
| curl -L -o qemu-macos.tar.xz $QEMU_MACOS_URL | |
| tar x -f qemu-macos.tar.xz | |
| echo "QEMU_EXEC=$PWD/qemu/bin/qemu-system-xtensa" >> $GITHUB_ENV | |
| elif [[ ${{ runner.os }} == "Windows" ]]; then | |
| curl -L -o qemu-windows.tar.xz $QEMU_WINDOWS_URL | |
| tar x -f qemu-windows.tar.xz | |
| echo "QEMU_EXEC=$PWD/qemu/bin/qemu-system-xtensa.exe" >> $GITHUB_ENV | |
| fi | |
| ls $QEMU_EXEC | |
| - name: Setup environment | |
| shell: bash | |
| run: | | |
| echo "ARTEMIS_CONFIG=${{ github.workspace }}/test_config" >> $GITHUB_ENV | |
| # Fetch the dependencies. Different for each platform. | |
| - name: Install dependencies - Linux | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update -y -q | |
| # sdl2 and libslirp are needed for Qemu. | |
| sudo apt-get install -y -q --no-install-recommends ninja-build libsdl2-2.0-0 libslirp0 | |
| ninja --version | |
| cmake --version | |
| - name: Install dependencies - macOS | |
| if: runner.os == 'macOS' | |
| run: | | |
| # sdl2 and libslirp are needed for Qemu. | |
| brew install ninja sdl2 libslirp | |
| ninja --version | |
| cmake --version | |
| - name: Install dependencies - Windows | |
| if: runner.os == 'Windows' | |
| run: | | |
| choco install ninja | |
| ninja --version | |
| cmake --version | |
| - name: Install Supabase | |
| if: matrix.run_supabase_tests | |
| uses: supabase/setup-cli@v1 | |
| with: | |
| version: ${{ env.SUPABASE_VERSION }} | |
| - name: Start Supabase - Toitware | |
| if: matrix.run_supabase_tests | |
| shell: bash | |
| working-directory: ${{ github.workspace }}/supabase_artemis | |
| run: | | |
| supabase start -x "$EXCLUDED_SUPABASE_SERVICES" | |
| supabase status | |
| # Sample output of supabase status: | |
| # supabase local development setup is running. | |
| # | |
| # API URL: http://localhost:54321 | |
| # DB URL: postgresql://postgres:postgres@localhost:54322/postgres | |
| # Studio URL: http://localhost:54323 | |
| # Inbucket URL: http://localhost:54324 | |
| # JWT secret: super-secret-jwt-token-with-at-least-32-characters-long | |
| # anon key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs | |
| # service_role key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSJ9.vI9obAHOGyVVKa3pD--kJlyxp-Z2zV9UUMAhKpNLAcU | |
| API_URL_LINE=$(supabase status | grep "API URL:") | |
| API_URL=${API_URL_LINE#*API URL: } | |
| API_HOST=${API_URL#*http://} | |
| ANON_KEY_LINE=$(supabase status | grep "anon key:") | |
| ANON_KEY=${ANON_KEY_LINE#*anon key: } | |
| echo "SUPABASE_TOITWARE_API_HOST=$API_HOST" >> $GITHUB_ENV | |
| echo "SUPABASE_TOITWARE_ANON_KEY=$ANON_KEY" >> $GITHUB_ENV | |
| - name: Start Supabase - Broker | |
| if: matrix.run_supabase_tests | |
| shell: bash | |
| working-directory: ${{ github.workspace }}/public/supabase_broker | |
| run: | | |
| supabase start -x "$EXCLUDED_SUPABASE_SERVICES" | |
| supabase status | |
| API_URL_LINE=$(supabase status | grep "API URL:") | |
| API_URL=${API_URL_LINE#*API URL: } | |
| API_HOST=${API_URL#*http://} | |
| ANON_KEY_LINE=$(supabase status | grep "anon key:") | |
| ANON_KEY=${ANON_KEY_LINE#*anon key: } | |
| echo "SUPABASE_BROKER_API_HOST=$API_HOST" >> $GITHUB_ENV | |
| echo "SUPABASE_BROKER_ANON_KEY=$ANON_KEY" >> $GITHUB_ENV | |
| - name: Run cmake | |
| shell: bash | |
| run: | | |
| make rebuild-cmake | |
| cmake \ | |
| -DQEMU_PATH="$QEMU_EXEC" \ | |
| build | |
| - name: Build binaries | |
| shell: bash | |
| run: | | |
| make | |
| - name: Test supabase | |
| if: matrix.run_supabase_tests | |
| shell: bash | |
| run: | | |
| make reload-supabase-schemas | |
| make test-supabase | |
| - name: Test | |
| if: (!matrix.run_supabase_tests) | |
| shell: bash | |
| run: | | |
| make disable-supabase-tests | |
| make test | |
| - name: Upload service for Testing org | |
| if: | | |
| matrix.upload-service && | |
| github.event_name == 'push' && | |
| github.ref == 'refs/heads/main' | |
| shell: bash | |
| env: | |
| ARTEMIS_EMAIL: leon@toit.io | |
| ARTEMIS_PASSWORD: ${{ secrets.LEON_ARTEMIS_PW }} | |
| run: | | |
| # We log in with the Artemis executable. | |
| # It will set the authentication in the config file which is also | |
| # used by the uploader. | |
| build/bin/artemis$BIN_EXTENSION auth login --email "$ARTEMIS_EMAIL" --password "$ARTEMIS_PASSWORD" | |
| SDK_VERSION=$(make dev-sdk-version) | |
| VERSION=$(cmake -DPRINT_VERSION=1 -P tools/gitversion.cmake) | |
| # It's hard to ensure that we don't upload a service with the same tag | |
| # as a release, and that would lead to trouble. | |
| # Add a T to indicate that this is a test version and avoid this problem. | |
| SERVICE_VERSION=$VERSION-T | |
| ARTEMIS_TESTING_ORGANIZATION=3ea5b632-5739-4f40-8446-2fc102a5b338 | |
| build/bin/uploader service \ | |
| --sdk-version $SDK_VERSION \ | |
| --service-version $SERVICE_VERSION \ | |
| --organization-id $ARTEMIS_TESTING_ORGANIZATION \ | |
| --local | |
| - name: Upload binary artifacts | |
| if: (!matrix.run_supabase_tests) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-${{ runner.os }} | |
| path: build/bin | |
| - name: Upload snapshot artifacts | |
| # Use 'always()' to upload them even if an earlier step failed. | |
| if: (!matrix.run_supabase_tests) && always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: snapshots-${{ runner.os }} | |
| path: build/snapshots | |
| - name: Upload other snapshots | |
| # Use 'always()' to upload them even if an earlier step failed. | |
| if: (!matrix.run_supabase_tests) && (runner.os != 'Windows') && always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: other-snapshots-${{ runner.os }} | |
| path: ${{ env.SNAPSHOTS_DIR }} | |
| arm64: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| submodules: true | |
| # We have a test that wants to tag a specific commit. | |
| # As such we need to fetch all history. | |
| fetch-depth: 0 | |
| - name: Setup Toit version | |
| id: constants | |
| shell: bash | |
| run: | | |
| export TOIT_VERSION=$(make dev-sdk-version) | |
| echo "toitVersion=$TOIT_VERSION" >> $GITHUB_OUTPUT | |
| - uses: toitlang/action-setup@v1 | |
| with: | |
| toit-version: ${{ steps.constants.outputs.toitVersion }} | |
| - name: Setup environment | |
| shell: bash | |
| run: | | |
| echo "ARTEMIS_CONFIG=${{ github.workspace }}/test_config" >> $GITHUB_ENV | |
| - name: Install dependencies - Linux | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update -y -q | |
| sudo apt-get install -y -q --no-install-recommends ninja-build | |
| ninja --version | |
| cmake --version | |
| - name: Configure | |
| shell: bash | |
| run: | | |
| make rebuild-cmake | |
| cmake -B build -DARTEMIS_ARCH=arm64 -DARTEMIS_OS=linux | |
| make disable-supabase-tests | |
| make disable-qemu-tests | |
| - name: Build binaries | |
| shell: bash | |
| run: | | |
| make | |
| - name: Start http-servers | |
| shell: bash | |
| run: | | |
| make start-http & | |
| echo "HTTP_PID=$!" >> $GITHUB_ENV | |
| sleep 10 | |
| make setup-local-dev | |
| mkdir -p $HOME/.config/artemis | |
| cp $HOME/.config/artemis-dev/config config | |
| - name: Test executables | |
| uses: pguyot/arm-runner-action@v2 | |
| with: | |
| cpu: cortex-a7 | |
| base_image: "raspios_lite_arm64:2022-01-28" | |
| image_additional_mb: 500 | |
| commands: | | |
| uname -m | |
| export HOME=$(pwd) | |
| export ARTEMIS_CONFIG=$HOME/config | |
| build/bin/artemis --version | |
| mkdir fleet | |
| export ARTEMIS_FLEET_ROOT=$PWD/fleet | |
| build/bin/artemis fleet init | |
| build/bin/artemis pod build -o test.pod fleet/my-pod.yaml | |
| - name: Kill http-servers | |
| shell: bash | |
| run: | | |
| kill $HTTP_PID | |
| serial: | |
| runs-on: serial-artemis | |
| steps: | |
| - name: Clean workspace | |
| run: | | |
| rm -rf ${{ github.workspace }}/* | |
| - uses: actions/checkout@v5 | |
| - name: Add local bin to PATH | |
| run: | | |
| echo "$HOME/local/bin" >> $GITHUB_PATH | |
| # Downloads the SDK that is defined in the Makefile | |
| # Reuses the SDK if it's already downloaded. | |
| - name: Setup Toit SDK | |
| run: | | |
| ARCHITECTURE=$(uname -m) | |
| SDK_VERSION=$(make dev-sdk-version) | |
| TOIT_SDK=$HOME/.cache/artemis/sdks/$SDK_VERSION | |
| # Check whether the SDK is already downloaded. | |
| if [[ -d $TOIT_SDK ]]; then | |
| echo "SDK already downloaded." | |
| else | |
| mkdir -p $HOME/.cache/artemis/sdks | |
| if [[ $ARCHITECTURE == "x86_64" ]]; then | |
| TAR_BALL_NAME=toit-linux | |
| elif [[ $ARCHITECTURE == "armv7l" ]]; then | |
| TAR_BALL_NAME=toit-rpi | |
| else | |
| echo "Unsupported architecture: $ARCHITECTURE" | |
| exit 1 | |
| fi | |
| wget https://github.com/toitlang/toit/releases/download/$SDK_VERSION/$TAR_BALL_NAME.tar.gz | |
| tar x -zf $TAR_BALL_NAME.tar.gz | |
| mv toit $TOIT_SDK | |
| fi | |
| echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_ENV | |
| echo "TOIT_SDK=$TOIT_SDK" >> $GITHUB_ENV | |
| echo "TOIT=$TOIT_SDK/bin/toit" >> $GITHUB_ENV | |
| - name: Run cmake | |
| shell: bash | |
| run: | | |
| make rebuild-cmake | |
| cmake -DTOIT="$TOIT" build | |
| # The SDK is already downloaded, but we might still need envelopes. | |
| - name: Download envelopes | |
| run: | | |
| make TOIT=$TOIT download-sdk | |
| - name: Disable Supabase tests | |
| run: | | |
| make TOIT=$TOIT disable-supabase-tests | |
| - name: Disable QEMU tests | |
| run: | | |
| make TOIT=$TOIT disable-qemu-tests | |
| - name: Build | |
| run: | | |
| make TOIT=$TOIT | |
| - name: Run serial tests | |
| run: | | |
| # Get the uart-port and wifi configuration from the file in the runner's home. | |
| source $HOME/artemis-test.env | |
| make TOIT=$TOIT test-serial | |
| # Erase the flash of the device. | |
| # We don't want it to behave erratically against the WiFi hotspot, | |
| # which could make future tests fail more easily. | |
| - name: Erase device flash | |
| if: always() | |
| run: | | |
| $TOIT_SDK/lib/toit/bin/esptool --port /dev/ttyArtemis erase_flash |