|
| 1 | +name: Run tox on Ubuntu 22.04 |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths-ignore: |
| 6 | + - 'docs/**' |
| 7 | + - '**/*.rst' |
| 8 | + - '**/*.md' |
| 9 | + branches: |
| 10 | + - master |
| 11 | + - main |
| 12 | + - '[0-9].[0-9]' |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - master |
| 16 | + - main |
| 17 | + |
| 18 | +jobs: |
| 19 | + start-runner: |
| 20 | + name: Start self-hosted EC2 runner |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + label: ${{ steps.start-ec2-runner.outputs.label }} |
| 24 | + ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} |
| 25 | + steps: |
| 26 | + - name: Configure AWS credentials |
| 27 | + uses: aws-actions/configure-aws-credentials@v1 |
| 28 | + with: |
| 29 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 30 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 31 | + aws-region: ${{ secrets.AWS_REGION }} |
| 32 | + - name: Start EC2 runner |
| 33 | + id: start-ec2-runner |
| 34 | + uses: machulav/ec2-github-runner@v2 |
| 35 | + with: |
| 36 | + mode: start |
| 37 | + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
| 38 | + # Ubuntu 22.04 region AMI |
| 39 | + ec2-image-id: ami-050b6fdb9f05d7b32 |
| 40 | + ec2-instance-type: c5.9xlarge |
| 41 | + subnet-id: ${{ secrets.AWS_EC2_SUBNET_ID }} |
| 42 | + security-group-id: ${{ secrets.AWS_EC2_SG_ID }} |
| 43 | + |
| 44 | + tox: |
| 45 | + name: Run tox on the runner |
| 46 | + needs: start-runner # required to start the main job when the runner is ready |
| 47 | + runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner |
| 48 | + steps: |
| 49 | + - name: checkout |
| 50 | + uses: actions/checkout@v3 |
| 51 | + |
| 52 | + - name: Print runner info |
| 53 | + run: | |
| 54 | + printf "Runner lscpu:\n$(lscpu)\n" |
| 55 | + printf "Runner lsmem:\n$(lsmem)\n" |
| 56 | + printf "Runner nproc:\n$(nproc)\n" |
| 57 | + printf "Runner uname:\n$(uname -a)\n" |
| 58 | + - name: Install benchmark dependencies |
| 59 | + run: | |
| 60 | + sudo apt update -y |
| 61 | + sudo apt install python3-pip -y |
| 62 | + sudo pip3 install --upgrade pip |
| 63 | + sudo apt install docker.io -y |
| 64 | + pip3 install -r dev_requirements.txt |
| 65 | +
|
| 66 | + - name: Install Poetry |
| 67 | + run: | |
| 68 | + curl -sSL https://install.python-poetry.org | python3 - |
| 69 | +
|
| 70 | + - name: Install Dev requirements |
| 71 | + run: | |
| 72 | + pip install -U setuptools wheel |
| 73 | + pip install -r dev_requirements.txt |
| 74 | +
|
| 75 | + - name: Run tox |
| 76 | + run: | |
| 77 | + tox |
| 78 | +
|
| 79 | + - name: Upload coverage to Codecov |
| 80 | + uses: codecov/codecov-action@v2 |
| 81 | + with: |
| 82 | + token: ${{secrets.CODECOV_TOKEN}} |
| 83 | + fail_ci_if_error: true |
| 84 | + |
| 85 | + stop-runner: |
| 86 | + name: Stop self-hosted EC2 runner |
| 87 | + needs: |
| 88 | + - start-runner # required to get output from the start-runner job |
| 89 | + - tox # required to wait when the main job is done |
| 90 | + runs-on: ubuntu-latest |
| 91 | + if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs |
| 92 | + steps: |
| 93 | + - name: Configure AWS credentials |
| 94 | + uses: aws-actions/configure-aws-credentials@v1 |
| 95 | + with: |
| 96 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 97 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 98 | + aws-region: ${{ secrets.AWS_REGION }} |
| 99 | + - name: Stop EC2 runner |
| 100 | + uses: machulav/ec2-github-runner@v2 |
| 101 | + with: |
| 102 | + mode: stop |
| 103 | + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
| 104 | + label: ${{ needs.start-runner.outputs.label }} |
| 105 | + ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} |
0 commit comments