-
-
Notifications
You must be signed in to change notification settings - Fork 335
212 lines (187 loc) · 6.82 KB
/
docker_latest.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Push latest Docker image
on:
push:
# Trigger if latest_candidate updates. This is automatically done by another
# workflow whenever tests pass on main - but events don't chain without using
# personal access tokens so we just use a cron job.
branches: [ latest_candidate ]
schedule:
# Run at 5:41 UTC daily
- cron: '41 5 * * *'
workflow_dispatch:
inputs:
branch:
description: "Branch from which to create the latest Docker image (default: latest_candidate)"
type: string
required: true
default: latest_candidate
disable_tests:
description: "Should the tests be skipped?"
type: boolean
required: True
default: False
platforms:
description: "Platforms to build"
type: choice
required: True
options:
- linux/amd64
- linux/arm64/v8
- linux/amd64,linux/arm64/v8
default: linux/amd64,linux/arm64/v8
tag:
description: "Tag for the resulting images"
type: string
required: True
default: 'latest'
env:
BRANCH: ${{ inputs.branch || 'latest_candidate' }}
PLATFORMS: ${{ inputs.platforms || 'linux/amd64,linux/arm64/v8' }}
TAG: ${{ inputs.tag || 'latest' }}
DOCKER_HUB_OWNER: ${{ vars.DOCKER_HUB_OWNER || github.repository_owner }}
jobs:
push_to_registry:
name: Push latest Docker image to Docker Hub
runs-on: ubuntu-22.04
if: ${{ vars.RUN_DAILY_BUILD }}
strategy:
matrix:
python-version: [3.11]
node-version: [22.x]
image:
# We build two images, `grist-oss` and `grist`.
# See https://github.com/gristlabs/grist-core?tab=readme-ov-file#available-docker-images
- name: "grist-oss"
repo: "grist-core"
- name: "grist"
repo: "grist-ee"
steps:
- name: Build settings
run: |
echo "Branch: $BRANCH"
echo "Platforms: $PLATFORMS"
echo "Docker Hub Owner: $DOCKER_HUB_OWNER"
echo "Tag: $TAG"
- name: Check out the repo
uses: actions/checkout@v4
with:
ref: ${{ env.BRANCH }}
- name: Add a dummy ext/ directory
run:
mkdir ext && touch ext/dummy
- name: Check out the ext/ directory
if: matrix.image.name != 'grist-oss'
run: buildtools/checkout-ext-directory.sh ${{ matrix.image.repo }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Prepare image but do not push it yet
uses: docker/build-push-action@v2
with:
context: .
load: true
tags: ${{ env.DOCKER_HUB_OWNER }}/${{ matrix.image.name }}:${{ env.TAG }}
cache-from: type=gha
build-contexts: ext=ext
- name: Use Node.js ${{ matrix.node-version }} for testing
if: ${{ !inputs.disable_tests }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Set up Python ${{ matrix.python-version }} for testing - maybe not needed
if: ${{ !inputs.disable_tests }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Python packages
if: ${{ !inputs.disable_tests }}
run: |
pip install virtualenv
yarn run install:python
- name: Install Node.js packages
if: ${{ !inputs.disable_tests }}
run: yarn install
- name: Disable the ext/ directory
if: ${{ !inputs.disable_tests }}
run: mv ext/ ext-disabled/
- name: Build Node.js code
if: ${{ !inputs.disable_tests }}
run: yarn run build:prod
- name: Install Google Chrome for Testing
run: ./test/test_env.sh node_modules/selenium-webdriver/bin/linux/selenium-manager
- name: Run tests with default settings
if: ${{ !inputs.disable_tests }}
run: |
export TEST_IMAGE=${{ env.DOCKER_HUB_OWNER }}/${{ matrix.image.name }}:${{ env.TAG }}
export VERBOSE=1
export DEBUG=1
export MOCHA_WEBDRIVER_HEADLESS=1
yarn run test:docker
- name: Run some tests with gvisor and python2
if: ${{ !inputs.disable_tests }}
run: |
export TEST_IMAGE=${{ env.DOCKER_HUB_OWNER }}/${{ matrix.image.name }}:${{ env.TAG }}
export VERBOSE=1
export DEBUG=1
export MOCHA_WEBDRIVER_HEADLESS=1
export GREP_TESTS='should support basic editing'
export TEST_DOCKER_OPTIONS='-e GRIST_SANDBOX_FLAVOR=gvisor -e PYTHON_VERSION_ON_CREATION=2'
yarn run test:docker
- name: Run some tests with gvisor and python3
if: ${{ !inputs.disable_tests }}
run: |
export TEST_IMAGE=${{ env.DOCKER_HUB_OWNER }}/${{ matrix.image.name }}:${{ env.TAG }}
export VERBOSE=1
export DEBUG=1
export MOCHA_WEBDRIVER_HEADLESS=1
export GREP_TESTS='should support basic editing'
export TEST_DOCKER_OPTIONS='-e GRIST_SANDBOX_FLAVOR=gvisor -e PYTHON_VERSION_ON_CREATION=3'
yarn run test:docker
- name: Re-enable the ext/ directory
if: ${{ !inputs.disable_tests }}
run: mv ext-disabled/ ext/
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to Docker Hub
uses: docker/build-push-action@v2
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ env.DOCKER_HUB_OWNER }}/${{ matrix.image.name }}:${{ env.TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-contexts: ext=ext
- name: Push Enterprise to Docker Hub
if: ${{ matrix.image.name == 'grist' }}
uses: docker/build-push-action@v2
with:
context: .
build-args: |
BASE_IMAGE=${{ env.DOCKER_HUB_OWNER }}/${{ matrix.image.name}}
BASE_VERSION=${{ env.TAG }}
file: ext/Dockerfile
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ env.DOCKER_HUB_OWNER }}/grist-ee:${{ env.TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
update_latest_branch:
name: Update latest branch
runs-on: ubuntu-22.04
needs: push_to_registry
steps:
- name: Check out the repo
uses: actions/checkout@v2
with:
ref: ${{ inputs.latest_branch }}
- name: Update latest branch
uses: ad-m/github-push-action@8407731efefc0d8f72af254c74276b7a90be36e1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: latest
force: true