Testing and Releasing pycmt #14
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: build-and-release | |
| run-name: Testing and Releasing pycmt | |
| on: [push, workflow_dispatch] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| environment: Main | |
| permissions: | |
| packages: write | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| images: | |
| - image: ubuntu | |
| plat: manylinux_2_39_riscv64 | |
| - image: alpine | |
| plat: musllinux_1_2_riscv64 | |
| steps: | |
| - name: Set Envs | |
| run: | | |
| echo "VERSION=0.0.0-dev" >> "$GITHUB_ENV" | |
| cat "$GITHUB_ENV" | |
| if: "!startsWith(github.ref, 'refs/tags/')" | |
| - name: Set Envs | |
| run: | | |
| echo "VERSION=${GITHUB_REF##*/v}" >> "$GITHUB_ENV" | |
| cat "$GITHUB_ENV" | |
| if: "startsWith(github.ref, 'refs/tags/')" | |
| # Remove this when cartesapp has full version | |
| - name: Install Cartesi Machine | |
| run: | | |
| curl -s -L https://cartesi.github.io/linux-packages/apt/keys/cartesi-deb-key.gpg.bin | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/cartesi-deb-key.gpg | |
| # Add repository | |
| curl -s -L https://cartesi.github.io/linux-packages/apt/stable/sources.list | sudo tee /etc/apt/sources.list.d/cartesi-deb-apt.list | |
| # Update list of available packages | |
| sudo apt-get update | |
| # Install cartesi-machine | |
| sudo apt-get install -y \ | |
| xgenext2fs=${{ vars.XGENEXT2_VERSION || '1.5.6-1' }} | |
| #cartesi-machine=${{ vars.EMULATOR_VERSION || '0.21.0-1' }} \ | |
| #cartesi-machine-linux-image=${{ vars.MACHINE_LINUX_VERSION || '0.21.0-1' }} | |
| curl -fsSL -o ${{ runner.temp }}/cartesi-machine.deb https://github.com/cartesi/machine-emulator/releases/download/v${{ vars.EMULATOR_VERSION || '0.21.0' }}/machine-emulator_amd64.deb | |
| sudo apt-get install -y --no-install-recommends ${{ runner.temp }}/cartesi-machine.deb | |
| curl -fsSL -o ${{ runner.temp }}/linux.bin https://github.com/cartesi/machine-linux-image/releases/download/v${{ vars.MACHINE_LINUX_VERSION || '0.21.0' }}/linux-${{ vars.KERNEL_VERSION || '6.5.13-ctsi-2' }}-v${{ vars.MACHINE_LINUX_VERSION || '0.21.0' }}.bin | |
| curl -fsSL -o ${{ runner.temp }}/linux.bin.sha512 https://github.com/cartesi/machine-linux-image/releases/download/v${{ vars.MACHINE_LINUX_VERSION || '0.21.0' }}/linux-${{ vars.KERNEL_VERSION || '6.5.13-ctsi-2' }}-v${{ vars.MACHINE_LINUX_VERSION || '0.21.0' }}.bin.sha512 | |
| - name: Check RAM image | |
| working-directory: ${{ runner.temp }} | |
| run: | | |
| echo "$(cut -d' ' -f1 linux.bin.sha512) linux.bin" | sha512sum -c - | |
| ls -l linux.bin | |
| - name: Check Cartesi Machine | |
| run: | | |
| cartesi-machine --version | |
| # Remove until here | |
| - uses: actions/checkout@v6 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Create virtual environment and install test suite | |
| run: | | |
| python3 -m venv .venv | |
| . .venv/bin/activate | |
| pip install --upgrade pip | |
| pip install "cartesapp[dev]@git+https://github.com/prototyp3-dev/cartesapp@v1.4.1a0" | |
| - name: Verify cartesapp CLI | |
| run: | | |
| . .venv/bin/activate | |
| cartesapp --help | |
| - name: Run tests | |
| run: | | |
| . .venv/bin/activate | |
| cartesapp test --cartesi-machine --config-file "./cartesi.echoApp.toml" --log-level debug --drive-config "root.dockerfile=sample_apps/echo_app/${{ matrix.images.image }}.dockerfile" | |
| - name: Build Wheels | |
| run: | | |
| docker build --platform=linux/riscv64 --build-arg PLAT=${{ matrix.images.plat }} -t ${{ matrix.images.image }}-builder -f ${{ matrix.images.image }}.dockerfile . | |
| docker run --rm --platform=linux/riscv64 -e VERSION=${{ env.VERSION }} -v $PWD:/mnt/build -w /mnt/build ${{ matrix.images.image }}-builder /mnt/build/build_wheels.sh | |
| mkdir -p ${{ runner.temp }}/artifacts/${{ matrix.images.image }}/ | |
| find wheelhouse/ -name "*${{ matrix.images.plat }}.whl" -exec cp '{}' ${{ runner.temp }}/artifacts/${{ matrix.images.image }}/. \; | |
| - name: Upload Wheels | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: pycmt-${{ matrix.images.plat }} | |
| path: ${{ runner.temp }}/artifacts/${{ matrix.images.image }}/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Set Envs | |
| run: | | |
| echo "VERSION=${GITHUB_REF##*/v}" >> "$GITHUB_ENV" | |
| - name: Setup | |
| run: | | |
| mkdir -p ${{ runner.temp }}/artifacts | |
| - name: Download Wheels | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: ${{ runner.temp }}/artifacts | |
| pattern: pycmt-* | |
| merge-multiple: true | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| prerelease: true | |
| files: ${{ runner.temp }}/artifacts/* | |
| fail_on_unmatched_files: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |