-
Notifications
You must be signed in to change notification settings - Fork 2
185 lines (173 loc) · 6.12 KB
/
build.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# This workflow will do a clean install, build the source code and run tests across different versions of node
# See: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Next.js CI
on:
pull_request:
branches: [master]
push:
branches: [master]
repository_dispatch:
types: [openreview-api-updated]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
env:
NEXT_PORT: 3030
SUPER_USER: openreview.net
services:
redis:
image: redis
ports:
- 6379:6379
strategy:
matrix:
node-version: [20.x]
steps:
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: 6.0
mongodb-replica-set: rs0
- name: Configure sysctl Limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Start Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 7.6.0
- name: Checkout openreview-py
uses: actions/checkout@v4
with:
repository: openreview/openreview-py
path: openreview-py
- name: Checkout openreview-api-v1
uses: actions/checkout@v4
with:
repository: openreview/openreview-api-v1
token: ${{ secrets.PAT_OPENREVIEW_IESL }}
path: openreview-api-v1
- name: Checkout openreview-api
uses: actions/checkout@v4
with:
repository: openreview/openreview-api
token: ${{ secrets.PAT_OPENREVIEW_IESL }}
path: openreview-api
- name: Checkout openreview-web
uses: actions/checkout@v4
with:
path: openreview-web
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: |
openreview-api/package-lock.json
openreview-web/package-lock.json
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Setup openreview-py
run: |
cd openreview-py
python -m pip install --upgrade pip
pip install -e .
- name: Setup openreview-api-v1
run: |
cd openreview-api-v1
mkdir -p logs files/attachments files/pdfs files/temp
npm ci
- name: Setup openreview-api
run: |
cd openreview-api
mkdir -p logs files/attachments files/pdfs files/temp
npm ci
- name: Cache openreview-web
id: openreview-web-cache
uses: actions/cache@v4
with:
# For explanation see https://nextjs.org/docs/advanced-features/ci-build-caching#github-actions
path: openreview-web/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('openreview-web/package-lock.json') }}-${{ hashFiles('openreview-web/**.js') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('openreview-web/package-lock.json') }}-
- name: Setup openreview-web
run: |
cd openreview-web
npm ci
cp .env.example .env.local
NODE_ENV=production SUPER_USER=openreview.net npm run build
- name: Run Unit Tests
run: |
cd openreview-web
npm run unit-test
- name: Run openreview-api-v1
run: |
cd openreview-api-v1
NODE_ENV=circleci node scripts/clean_start_app.js &
- name: Run openreview-api
run: |
cd openreview-api
NODE_ENV=circleci node scripts/setup_app.js &
- name: Run openreview-web
run: |
cd openreview-web
NODE_ENV=production SUPER_USER=openreview.net npm run start &
- name: Run TestCafe Tests
run: |
cd openreview-web
xvfb-run --server-args="-screen 0 1280x720x24" npm run test
- name: Upload Test Videos
if: failure()
uses: actions/upload-artifact@v4
with:
name: TestCafe Videos
path: openreview-web/videos/
- name: Check API Logs
if: failure()
run: |
cd openreview-api/logs
cat "$(ls -rt | tail -n1)"
deploy:
# Allow the job to fetch a GitHub ID token
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Add SSH key
run: |
mkdir -p /home/runner/.ssh
echo "${{ secrets.GCLOUD_SSH_KEY }}" > /home/runner/.ssh/google_compute_engine
echo "${{ secrets.GCLOUD_SSH_KEY_PUB }}" > /home/runner/.ssh/google_compute_engine.pub
chmod 600 /home/runner/.ssh/google_compute_engine
chmod 600 /home/runner/.ssh/google_compute_engine.pub
- name: Authenticate with Google Cloud
id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
create_credentials_file: true
cleanup_credentials: true
export_environment_variables: true
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
skip_install: true
- name: Deploy to dev
run: |
gcloud compute ssh --zone "us-central1-b" openreview@dev-instance-1 --command 'export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && bash bin/deploy-web.sh' --quiet
gcloud compute ssh --zone "us-central1-b" openreview@dev-instance-1 --command 'export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && bash bin/deploy-openreview-py.sh' --quiet