|
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | + |
| 3 | +name: "Run smoke tests via Tox::pytest (python 3.12)" |
| 4 | +# These tests will be long running and require accelerated hardware. |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + branch: |
| 10 | + type: string |
| 11 | + default: main |
| 12 | + # using this rather than pull_request because this workflow |
| 13 | + # needs to run in the context of the base branch (main) and |
| 14 | + # access the repo's secrets to start the AWS instances. |
| 15 | + pull_request_target: |
| 16 | + branches: |
| 17 | + - main |
| 18 | + - release-* |
| 19 | + paths: |
| 20 | + # note this should match the merging criteria in 'mergify.yml' |
| 21 | + - "**.py" |
| 22 | + - "tox.ini" |
| 23 | + - "pyproject.toml" |
| 24 | + - "requirements-dev.txt" |
| 25 | + - "requirements-cuda.txt" |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: read |
| 29 | + |
| 30 | +defaults: |
| 31 | + run: |
| 32 | + shell: bash |
| 33 | + |
| 34 | +env: |
| 35 | + ec2_runner_variant: "g6e.12xlarge" # 4x L40s |
| 36 | + |
| 37 | +jobs: |
| 38 | + start-large-ec2-runner: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + outputs: |
| 41 | + label: ${{ steps.launch-ec2-instance-with-fallback.outputs.label }} |
| 42 | + ec2-instance-id: ${{ steps.launch-ec2-instance-with-fallback.outputs.ec2-instance-id }} |
| 43 | + ec2-instance-region: ${{ steps.launch-ec2-instance-with-fallback.outputs.ec2-instance-region }} |
| 44 | + steps: |
| 45 | + - name: Checkout "launch-ec2-runner-with-fallback" in-house CI action |
| 46 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 47 | + with: |
| 48 | + repository: instructlab/ci-actions |
| 49 | + # clone the "ci-actions" repo to a local directory called "ci-actions", instead of overwriting the current WORKDIR contents |
| 50 | + path: ci-actions |
| 51 | + ref: release-v0.1 |
| 52 | + sparse-checkout: | |
| 53 | + actions/launch-ec2-runner-with-fallback |
| 54 | +
|
| 55 | + - name: Launch EC2 Runner with Fallback |
| 56 | + id: launch-ec2-instance-with-fallback |
| 57 | + uses: ./ci-actions/actions/launch-ec2-runner-with-fallback |
| 58 | + env: |
| 59 | + TMPDIR: "/tmp" |
| 60 | + with: |
| 61 | + aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 62 | + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 63 | + github_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
| 64 | + regions_config: > |
| 65 | + [ |
| 66 | + { |
| 67 | + "region": "us-east-2", |
| 68 | + "subnets": { |
| 69 | + "us-east-2a": "${{ vars.SUBNET_US_EAST_2A }}", |
| 70 | + "us-east-2b": "${{ vars.SUBNET_US_EAST_2B }}", |
| 71 | + "us-east-2c": "${{ vars.SUBNET_US_EAST_2C }}" |
| 72 | + }, |
| 73 | + "ec2-ami": "${{ vars.AWS_EC2_AMI_US_EAST_2 }}", |
| 74 | + "security-group-id": "${{ vars.SECURITY_GROUP_ID_US_EAST_2 }}" |
| 75 | + }, |
| 76 | + { |
| 77 | + "region": "us-east-1", |
| 78 | + "subnets": { |
| 79 | + "us-east-1a": "${{ vars.SUBNET_US_EAST_1A }}", |
| 80 | + "us-east-1b": "${{ vars.SUBNET_US_EAST_1B }}", |
| 81 | + "us-east-1c": "${{ vars.SUBNET_US_EAST_1C }}", |
| 82 | + "us-east-1d": "${{ vars.SUBNET_US_EAST_1D }}", |
| 83 | + "us-east-1e": "${{ vars.SUBNET_US_EAST_1E }}", |
| 84 | + "us-east-1f": "${{ vars.SUBNET_US_EAST_1F }}" |
| 85 | + }, |
| 86 | + "ec2-ami": "${{ vars.AWS_EC2_AMI_US_EAST_1 }}", |
| 87 | + "security-group-id": "${{ vars.SECURITY_GROUP_ID_US_EAST_1 }}" |
| 88 | + } |
| 89 | + ] |
| 90 | + try_spot_instance_first: false |
| 91 | + ec2_instance_type: g6e.12xlarge |
| 92 | + aws_resource_tags: > |
| 93 | + [ |
| 94 | + {"Key": "Name", "Value": "instructlab-training-ci-github-large-runner"}, |
| 95 | + {"Key": "GitHubRepository", "Value": "${{ github.repository }}"}, |
| 96 | + {"Key": "GitHubRef", "Value": "${{ github.ref }}"}, |
| 97 | + {"Key": "GitHubPR", "Value": "${{ github.event.number }}"} |
| 98 | + ] |
| 99 | +
|
| 100 | + run-smoke-tests: |
| 101 | + needs: |
| 102 | + - start-large-ec2-runner |
| 103 | + runs-on: ${{needs.start-large-ec2-runner.outputs.label}} |
| 104 | + # It is important that this job has no write permissions and has |
| 105 | + # no access to any secrets. This part is where we are running |
| 106 | + # untrusted code from PRs. |
| 107 | + permissions: {} |
| 108 | + steps: |
| 109 | + - name: "Checkout code" |
| 110 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 111 | + with: |
| 112 | + fetch-depth: 0 |
| 113 | + ref: ${{inputs.branch}} |
| 114 | + |
| 115 | + - name: Run smoke tests |
| 116 | + uses: ./.github/actions/run-smoke |
| 117 | + with: |
| 118 | + python-version: 3.12 |
| 119 | + |
| 120 | + stop-large-ec2-runner: |
| 121 | + needs: |
| 122 | + - start-large-ec2-runner |
| 123 | + - run-smoke-tests |
| 124 | + runs-on: ubuntu-latest |
| 125 | + if: ${{ always() }} |
| 126 | + steps: |
| 127 | + - name: "Harden runner" |
| 128 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.10.1 |
| 129 | + with: |
| 130 | + egress-policy: audit |
| 131 | + |
| 132 | + - name: "Configure AWS credentials" |
| 133 | + uses: "aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722" # v4.1.0 |
| 134 | + with: |
| 135 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 136 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 137 | + aws-region: ${{ needs.start-large-ec2-runner.outputs.ec2-instance-region }} |
| 138 | + |
| 139 | + - name: "Stop EC2 runner" |
| 140 | + uses: machulav/ec2-github-runner@a8c20fc0876503410b2b966c124abc2311984ce2 # v2.3.9 |
| 141 | + with: |
| 142 | + mode: stop |
| 143 | + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
| 144 | + label: ${{ needs.start-large-ec2-runner.outputs.label }} |
| 145 | + ec2-instance-id: ${{ needs.start-large-ec2-runner.outputs.ec2-instance-id }} |
0 commit comments