feat: integrate numpy as statically-linked built-in module #18
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: Nanvix Python CI | |
| on: | |
| repository_dispatch: | |
| types: [cpython-release] | |
| workflow_dispatch: | |
| pull_request: | |
| branches: | |
| - main | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| issues: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref_name || 'default' }} | |
| cancel-in-progress: true | |
| jobs: | |
| get-release-info: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| cpython_tag: ${{ steps.info.outputs.cpython_tag }} | |
| nanvix_sha: ${{ steps.info.outputs.nanvix_sha }} | |
| short_sha: ${{ steps.info.outputs.short_sha }} | |
| steps: | |
| - name: Determine Release Info | |
| id: info | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| # Determine cpython tag from dispatch payload, manual input, or latest release | |
| if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then | |
| CPYTHON_TAG="${{ github.event.client_payload.cpython_tag }}" | |
| NANVIX_SHA="${{ github.event.client_payload.nanvix_sha }}" | |
| elif [[ -n "${{ github.event.inputs.cpython_tag || '' }}" ]]; then | |
| CPYTHON_TAG="${{ github.event.inputs.cpython_tag }}" | |
| NANVIX_SHA="" | |
| else | |
| # Fetch latest release tag from cpython repo | |
| CPYTHON_TAG=$(gh api repos/nanvix/cpython/releases/latest --jq '.tag_name' 2>/dev/null || echo "") | |
| NANVIX_SHA="" | |
| fi | |
| if [[ -z "$CPYTHON_TAG" ]]; then | |
| echo "::error::Could not determine CPython release tag" | |
| exit 1 | |
| fi | |
| # Extract nanvix SHA from tag if not provided (tag format: <cpython-sha>-nanvix-<nanvix-sha>) | |
| if [[ -z "$NANVIX_SHA" ]]; then | |
| NANVIX_SHA=$(echo "$CPYTHON_TAG" | sed -E 's/.*-nanvix-([a-f0-9]+)$/\1/' || echo "") | |
| fi | |
| # Prefer Nanvix SHA for build identification; fallback to CPython tag prefix. | |
| SOURCE_SHA="$NANVIX_SHA" | |
| if [[ -z "$SOURCE_SHA" ]]; then | |
| SOURCE_SHA="$CPYTHON_TAG" | |
| fi | |
| SHORT_SHA=$(echo "$SOURCE_SHA" | sed -E 's/^([a-f0-9]{7,40}).*/\1/' | cut -c1-7) | |
| if [[ -z "$SHORT_SHA" ]]; then | |
| SHORT_SHA="unknown" | |
| fi | |
| echo "cpython_tag=$CPYTHON_TAG" >> "$GITHUB_OUTPUT" | |
| echo "nanvix_sha=$NANVIX_SHA" >> "$GITHUB_OUTPUT" | |
| echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT" | |
| echo "CPython tag: $CPYTHON_TAG" | |
| echo "Nanvix SHA: $NANVIX_SHA" | |
| echo "Short SHA: $SHORT_SHA" | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: hyperlight | |
| process-mode: multi-process | |
| - platform: hyperlight | |
| process-mode: single-process | |
| - platform: microvm | |
| process-mode: single-process | |
| - platform: microvm | |
| process-mode: multi-process | |
| name: ${{ matrix.platform }}-${{ matrix.process-mode }} | |
| container: | |
| image: nanvix/toolchain:latest-minimal | |
| options: --device /dev/kvm | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| NANVIX_TOOLCHAIN: /opt/nanvix | |
| NANVIX_PLATFORM: ${{ matrix.platform }} | |
| NANVIX_PROCESS_MODE: ${{ matrix.process-mode }} | |
| USER: runner | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| fetch-depth: 1 | |
| - name: Setup | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| curl -fsSL https://bootstrap.pypa.io/get-pip.py | python3 - --break-system-packages | |
| ./z setup | |
| - name: Build | |
| run: ./z build | |
| - name: Test | |
| run: ./z test | |
| - name: Collect failure logs | |
| if: ${{ failure() }} | |
| run: | | |
| mkdir -p ci-logs | |
| cp -f /tmp/*.log ci-logs/ 2>/dev/null || true | |
| if [[ -d .nanvix ]]; then | |
| find .nanvix -type f \( -name "*.log" -o -name "config.log" \) -print0 \ | |
| | xargs -0 -I{} cp -f "{}" ci-logs/ 2>/dev/null || true | |
| fi | |
| if [[ -d deps/cpython ]]; then | |
| find deps/cpython -type f -name "config.log" -print0 \ | |
| | xargs -0 -I{} cp -f "{}" ci-logs/ 2>/dev/null || true | |
| fi | |
| ls -lah ci-logs || true | |
| - name: Upload failure logs | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: failure-logs-${{ matrix.platform }}-${{ matrix.process-mode }} | |
| path: ci-logs/* | |
| if-no-files-found: warn | |
| - name: Collect runtime artifacts | |
| if: ${{ success() }} | |
| run: ./z release | |
| - name: Upload runtime artifacts | |
| if: ${{ success() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: runtime-artifacts-${{ matrix.platform }}-${{ matrix.process-mode }} | |
| path: release-assets/* | |
| if-no-files-found: error | |
| release-runtime-artifacts: | |
| needs: [test, get-release-info] | |
| if: >- | |
| ${{ success() && | |
| (github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch' || github.event_name == 'push') }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download runtime artifacts from all test jobs | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: runtime-artifacts-* | |
| merge-multiple: true | |
| path: release-assets | |
| - name: Create release with runtime artifacts | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: runtime-${{ needs.get-release-info.outputs.cpython_tag }} | |
| name: Build ${{ needs.get-release-info.outputs.short_sha }} | |
| body: | | |
| Runtime artifacts generated by CI after successful tests. | |
| - Commit: ${{ github.sha }} | |
| - Workflow run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| files: | | |
| release-assets/*.tar.bz2 | |
| overwrite_files: true | |
| report-failure: | |
| needs: [test] | |
| if: >- | |
| ${{ always() && | |
| github.event_name == 'repository_dispatch' && | |
| needs.test.result == 'failure' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Create failure issue | |
| uses: actions/github-script@v7 | |
| env: | |
| TEST_RESULT: ${{ needs.test.result }} | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
| const title = `Functional test failure for ${context.sha.substring(0, 7)}`; | |
| const body = [ | |
| `Functional tests failed for commit \`${context.sha}\`.`, | |
| `- Trigger: ${context.eventName}`, | |
| `- Run: [#${context.runNumber}](${runUrl})`, | |
| `- test result: ${process.env.TEST_RESULT}`, | |
| '', | |
| 'Please investigate and take any corrective actions.' | |
| ].join('\n'); | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title, | |
| body, | |
| assignees: ['ppenna'] | |
| }); |