1
+ name : integration-tests
2
+ on : [workflow_call]
3
+ jobs :
4
+ start-runner :
5
+ name : Start self-hosted EC2 runner
6
+ runs-on : ubuntu-latest
7
+ outputs :
8
+ label : ${{ steps.start-ec2-runner.outputs.label }}
9
+ ec2-instance-id : ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
10
+ steps :
11
+ - name : Configure AWS credentials
12
+ uses : aws-actions/configure-aws-credentials@v2
13
+ with :
14
+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
15
+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
16
+ aws-region : ${{ secrets.AWS_REGION }}
17
+ - name : Start EC2 runner
18
+ id : start-ec2-runner
19
+ uses : machulav/ec2-github-runner@v2
20
+ with :
21
+ mode : start
22
+ github-token : ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
23
+ ec2-image-id : ami-0f57c48465f6361a6
24
+ ec2-instance-type : r5a.4xlarge
25
+ subnet-id : subnet-a4b769c3
26
+ security-group-id : sg-06a2ae324a6e68d4d
27
+ aws-resource-tags : >
28
+ [
29
+ {"Key": "Name", "Value": "scout-github-runner"},
30
+ {"Key": "billingId", "Value": "210109"},
31
+ {"Key": "org", "Value": "scout"}
32
+ ]
33
+
34
+ run-test :
35
+ name : Integration Testing
36
+ needs : start-runner
37
+ runs-on : ${{ needs.start-runner.outputs.label }}
38
+ steps :
39
+ - uses : actions/checkout@v3
40
+ with :
41
+ ref : ${{ github.head_ref }}
42
+ - name : Set up Python 3.10
43
+ uses : actions/setup-python@v4
44
+ with :
45
+ python-version : ' 3.10'
46
+ - name : Install Python dependencies
47
+ run : |
48
+ python -m pip install --upgrade pip
49
+ pip install numpy>=1.16 pandas>=2.2 scipy requests numpy-financial matplotlib xlsxwriter
50
+ - name : Run workflow
51
+ run : python tests/integration_testing/run_workflow.py
52
+ - name : Upload artifacts
53
+ uses : actions/upload-artifact@v3
54
+ with :
55
+ name : results
56
+ path : ./results/*.json
57
+ - name : Commit test results
58
+ run : |
59
+ branch_name="${{ github.head_ref }}"
60
+ git pull origin $branch_name
61
+ cp -r ./results/*.json ./tests/integration_testing/results
62
+ git add ./tests/integration_testing/*.json
63
+ if [[ $(git diff --cached --exit-code) ]]; then
64
+ git config --system user.email "[email protected] "
65
+ git config --system user.name "GitHub Action"
66
+ git commit -m "Upload results files from CI build"
67
+ echo "Pushing to branch: $branch_name"
68
+ git push -u origin $branch_name
69
+ fi
70
+
71
+ stop-runner :
72
+ name : Stop self-hosted EC2 runner
73
+ needs :
74
+ - start-runner # required to get output from the start-runner job
75
+ - run-test # required to wait when the main job is done
76
+ runs-on : ubuntu-latest
77
+ if : ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
78
+ steps :
79
+ - name : Configure AWS credentials
80
+ uses : aws-actions/configure-aws-credentials@v2
81
+ with :
82
+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
83
+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
84
+ aws-region : ${{ secrets.AWS_REGION }}
85
+ - name : Stop EC2 runner
86
+ uses : machulav/ec2-github-runner@v2
87
+ with :
88
+ mode : stop
89
+ github-token : ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
90
+ label : ${{ needs.start-runner.outputs.label }}
91
+ ec2-instance-id : ${{ needs.start-runner.outputs.ec2-instance-id }}
0 commit comments