-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (107 loc) · 4.04 KB
/
build_app.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
105
106
107
108
109
110
111
112
113
114
name: Build portal-backend
on:
pull_request:
workflow_dispatch:
push:
branches:
- "master"
- "internal"
- "qa"
- "peddep*"
- "dmc*"
- "external*"
- "test-*"
env:
DOCKER_REPO: us.gcr.io/broad-achilles/depmap
DOCKER_TAG: ga2-build-${{ github.run_number }}
jobs:
run-frontend-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node 19.4.0
uses: actions/setup-node@v3
with:
node-version: 19.4.0
- name: Install yarn dependencies
run: "cd frontend && NODE_OPTIONS='--openssl-legacy-provider' CI=true yarn install"
- name: Build webpack
run: "cd frontend && NODE_OPTIONS='--openssl-legacy-provider --max_old_space_size=4096' yarn build:portal"
- name: Run tests
run: yarn --cwd frontend test
build-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn --cwd frontend cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Update build id
run: |
echo "SHA: ${{ github.sha }} Build: ${{ github.run_number }}" > portal-backend/depmap/templates/build_info.html
echo "SHA=\"${{ github.sha }}\"" > portal-backend/depmap/settings/build.py
echo "BUILD=\"${{ github.run_number }}\"" >> portal-backend/depmap/settings/build.py
- name: Login to GCR
uses: docker/login-action@v2
with:
registry: us.gcr.io
username: _json_key
password: ${{ secrets.DEPMAP_DEPLOY_SVC_ACCT }}
- name: Build Docker image
run: cd portal-backend && bash build-docker-image.sh ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }}
- name: Run pyright-ratchet
run: docker run -e HOME=/install/pyright ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }} pyright-ratchet
- name: Run import linter
run: docker run ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }} lint-imports
- name: Push Docker image
run: docker push ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }}
run-pytest:
runs-on: ubuntu-latest
needs: build-docker
strategy:
matrix:
pytest-group: [1, 2, 3, 4, 5]
steps:
- uses: actions/checkout@v3
- name: Login to GCR
uses: docker/login-action@v2
with:
registry: us.gcr.io
username: _json_key
password: ${{ secrets.DEPMAP_DEPLOY_SVC_ACCT }}
- name: Pull Docker image
run: docker pull ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }}
- name: Get pytest durations
uses: actions/cache@v3
with:
path: .test_durations
key: ${{ runner.os }}-pytest-durations
- name: Run pytest
run: cd portal-backend && docker run -v $PWD/../.test_durations:/install/.test_durations -e PYTHONWARNINGS="ignore::DeprecationWarning" ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }} pytest --splits 5 --group ${{ matrix.pytest-group }}
push-docker-tags:
runs-on: ubuntu-latest
needs:
- run-pytest
- run-frontend-tests
steps:
- uses: actions/checkout@v3
- name: Login to GCR
uses: docker/login-action@v2
with:
registry: us.gcr.io
username: _json_key
password: ${{ secrets.DEPMAP_DEPLOY_SVC_ACCT }}
- name: Pull Docker image
run: docker pull ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }}
- name: Push Docker tags
run: |
chmod +x ./.github/push_docker.py
# GITHUB_REF##*/ is github actions magic which expands to the branch name
./.github/push_docker.py ${{env.DOCKER_REPO}} ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }} ${GITHUB_REF##*/}