samcli-direct #39
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: samcli-direct | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| types: | |
| - closed | |
| schedule: | |
| - cron: '0 8 * * *' | |
| workflow_dispatch: | |
| env: | |
| GO_VERSION: '1.24.x' | |
| CONTAINERD_VERSION: '2.0.x' | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| samcli-direct-test: | |
| if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 # start-api is the longest at ~ 20 minutes | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| test_step: | |
| - name: unit | |
| - name: package | |
| - name: start-lambda | |
| - name: invoke | |
| - name: start-api | |
| env: | |
| AWS_DEFAULT_REGION: "${{ secrets.REGION }}" | |
| DOCKER_HOST: unix:///var/run/finch.sock | |
| DOCKER_CONFIG: $HOME/.finch | |
| BY_CANARY: true # allows full testing | |
| SAM_CLI_DEV: 1 | |
| SAM_CLI_TELEMETRY: 0 | |
| steps: | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df # v4.2.1 | |
| with: | |
| role-to-assume: ${{secrets.SAMCLI_DIRECT_ROLE_BASE}} | |
| role-session-name: samcli-${{ matrix.test_step.name }}-tests | |
| aws-region: ${{ secrets.REGION }} | |
| role-duration-seconds: 2000 | |
| - name: Set up Go | |
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| # from aws/aws-sam-cli/setup.py: python_requires=">=3.9, <=4.0, !=4.0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Checkout finch-daemon | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| submodules: recursive | |
| - name: Stop pre-existing services | |
| run: | | |
| sudo systemctl stop docker | |
| sudo systemctl stop containerd | |
| - name: Remove default podman network config | |
| run: | | |
| sudo rm -f /etc/cni/net.d/87-podman-bridge.conflist | |
| - name: Clean up Daemon socket | |
| run: | | |
| sudo rm -f /run/finch.sock | |
| sudo rm -f /run/finch.pid | |
| sudo rm -f /run/finch-credential.sock | |
| - name: Install finch-daemon dependencies | |
| run: | | |
| ./setup-test-env.sh | |
| sleep 10 | |
| - name: Build and start finch-daemon | |
| run: | | |
| make build | |
| sudo bin/finch-daemon --debug --socket-owner $UID 2>&1 | tee finch-daemon.log & | |
| sleep 10 | |
| - name: Get latest SAM CLI tag | |
| id: sam-tag | |
| run: | | |
| TAG=$(curl -s https://api.github.com/repos/aws/aws-sam-cli/releases/latest | jq -r .tag_name) | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| - name: Checkout SAM CLI | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: aws/aws-sam-cli | |
| submodules: recursive | |
| path: aws-sam-cli | |
| ref: ${{ steps.sam-tag.outputs.tag }} | |
| - name: Set up SAM CLI from source | |
| working-directory: aws-sam-cli | |
| run: | | |
| python -m pip install --upgrade pip | |
| make init | |
| samdev --version | |
| - name: Run unit tests | |
| if: matrix.test_step.name == 'unit' | |
| run: ./scripts/samcli-direct/run-unit-tests.sh | |
| - name: Run package tests | |
| if: matrix.test_step.name == 'package' | |
| run: ./scripts/samcli-direct/run-package-tests.sh | |
| - name: Run invoke tests | |
| if: matrix.test_step.name == 'invoke' | |
| run: ./scripts/samcli-direct/run-invoke-tests.sh | |
| - name: Run start-lambda tests | |
| if: matrix.test_step.name == 'start-lambda' | |
| run: ./scripts/samcli-direct/run-start-lambda-tests.sh | |
| - name: Run start-api tests | |
| if: matrix.test_step.name == 'start-api' | |
| run: ./scripts/samcli-direct/run-start-api-tests.sh | |
| - name: Show finch-daemon logs | |
| if: always() | |
| run: | | |
| echo "=== FINCH-DAEMON OUTPUT ===" | |
| cat finch-daemon.log | |
| # ensuring resources are clean post-test | |
| cleanup: | |
| runs-on: ubuntu-latest | |
| needs: samcli-direct-test | |
| if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df | |
| with: | |
| role-to-assume: ${{ secrets.SAMCLI_DIRECT_ROLE_BASE }} | |
| role-session-name: cleanup-samcli-direct | |
| aws-region: ${{ secrets.REGION }} | |
| - name: Comprehensive AWS resource cleanup | |
| timeout-minutes: 10 | |
| run: ./scripts/cleanup-aws-resources.sh |