-
Notifications
You must be signed in to change notification settings - Fork 2
104 lines (101 loc) · 3.83 KB
/
run-ats.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Run ATS
on:
workflow_call:
inputs:
repo:
type: string
required: true
app_container_name:
type: string
required: false
default: "app"
use_action:
type: boolean
required: false
default: false
install_cli:
required: false
default: false
type: boolean
description: "Whether to install the Codecov CLI. Set to false if you have previously installed the CLI."
run_tests:
required: false
default: true
type: boolean
description: "Whether to run the tests with the given command in the container. If set to true, this will run the test command and upload to Codecov"
test_command:
required: false
default: "python -m pytest --cov=./"
type: string
description: "Command to run in container to execute tests. Required when run_tests is true. This should be `pytest` with the desired args at this point."
codecov_cli_upload_args:
required: false
type: string
default: ""
description: "List of args to pass to cli on upload. This is kind of a hack pending a more robust solution"
codecov_cli_yml_path:
required: false
type: string
default: "--codecov-yml-path=codecov_cli.yml"
description: "Path to codecov cli yml. Currently expected to include flag as well --codecov-yml-path=codecov_cli.yml for ex."
env:
AR_REPO: ${{ inputs.repo }}
jobs:
ats:
name: ATS
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache App
id: cache-app
uses: actions/cache@v4
env:
cache-name: cache-app
with:
path: |
app.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
- name: Load built image
run: |
docker load --input app.tar
make tag.latest
- name: Install docker compose
run: |
sudo curl -SL https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Bring test env up
run: |
make test_env.up
- name: Prepare for tests
run: |
make test_env.prepare
make test_env.check_db
- name: Get app container id
if: inputs.use_action
id: get-container-id
run: |
echo "app_container_id=$(docker-compose ps ${{ inputs.app_container_name }} -q | cut -c1-12 )" >> $GITHUB_OUTPUT
- id: test-upload
name: Run tests and upload to Codecov
if: inputs.use_action == false
run: |
make test_env.static_analysis CODECOV_STATIC_TOKEN=${{ secrets.STATIC_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_ATS_URL }}
make test_env.label_analysis CODECOV_STATIC_TOKEN=${{ secrets.STATIC_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_ATS_URL }}
make test_env.ats CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_ORG_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_ATS_URL }}
- id: test-upload-action
uses: codecov/codecov-ats-docker@main
if: inputs.use_action
name: Run tests and upload to Codecov via action
with:
container: ${{ steps.get-container-id.outputs.app_container_id }}
codecov_cli_yml_path: ${{ inputs.codecov_cli_yml_path }}
codecov_cli_upload_args: ${{ inputs.codecov_cli_upload_args }}
static_token: ${{ secrets.STATIC_TOKEN }}
codecov_token: ${{ secrets.CODECOV_ORG_TOKEN }}
install_cli: ${{ inputs.install_cli }}
run_tests: ${{ inputs.run_tests }}
test_command: ${{ inputs.test_command }}
codecov_url: ${{ secrets.CODECOV_ATS_URL }}