Skip to content

Commit

Permalink
Reinstate AWS runner.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggorman committed Jul 19, 2024
1 parent a0c1a66 commit 77ffe6d
Showing 1 changed file with 107 additions and 0 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/pytest-aws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: aws-ci

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
pull_request:
branches:
- master

jobs:

start-runner:
name: Start self-hosted EC2 runner
runs-on: ubuntu-latest

outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}

steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: "us-east-1"

- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.AWS_CI_PAT }}
ec2-image-id: ami-0f2acee8eccac59fd
ec2-instance-type: c6g.4xlarge
subnet-id: subnet-0b4c118eb6ae48d63
security-group-id: sg-0b51f45ce1c1ad78f
aws-resource-tags: > # optional, requires additional permissions
[
{"Key": "Name", "Value": "ec2-github-runner"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
do-the-job:
name: Do the job on the runner
needs: start-runner # required to start the main job when the runner is ready
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner

env:
DEVITO_ARCH: "arm"
DEVITO_PLATFORM: "graviton"
DEVITO_LANGUAGE: "openmp"
OMP_NUM_THREADS: 2

steps:
- name: Checkout devito
uses: actions/checkout@v3

- name: Check arch
run: lscpu

- name: Install dependencies
if: "!contains(matrix.name, 'docker')"
run: |
pip3 install --upgrade pip
pip3 install -U -e .[tests]
pip3 install pytest-xdist
- name: Test with pytest
run: pytest -n 8 -k "not adjoint" -m "not parallel" --cov --cov-config=.coveragerc --cov-report=xml tests/

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: ${{ matrix.name }}

stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-runner # required to get output from the start-runner job
- do-the-job # required to wait when the main job is done
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs

steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.AWS_CI_PAT }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}

0 comments on commit 77ffe6d

Please sign in to comment.