-
Notifications
You must be signed in to change notification settings - Fork 2
144 lines (130 loc) · 4.88 KB
/
ci.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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
repository_dispatch:
# Gets triggered by toitlang/toit whenever a release is created or edited.
types: [new-release]
jobs:
build:
# We're running on ubuntu-latest, nothing special
runs-on: ubuntu-latest
steps:
# As usual, we simply checkout the project
- name: Checkout
uses: actions/checkout@v3
# This action is provided by Cypress. It installs node and the NPM
# dependencies, and caches them.
- name: Cypress install
uses: cypress-io/github-action@v5
with:
# NOTE: we don't actually run tests here!
runTests: false
- name: Download latest releases
run: |
curl https://api.github.com/repos/toitlang/toit/releases > src/lib/releases.json
npm exec -- prettier -w src/lib/releases.json
# Now we run our lints. This is the place where you could run other tests
# unrelated to cypress (e.g.: unit tests).
- name: Run lints
run: npm run lint
# Now we're building the svelte site.
# This step generates a build/ directory.
- name: Build site
run: npm run build
# And lastly, we upload the generated build/ folder as artifact so we can
# use it in later steps.
- name: Upload build and .svelte-kit folder
uses: actions/upload-artifact@v3
with:
name: build
if-no-files-found: error
path: build
test:
# We depend on the build step for this.
needs: build
timeout-minutes: 15
runs-on: ubuntu-latest
# We need to use the cypress container here, that includes chrome and
# firefox.
container:
image: cypress/browsers:node14.17.0-chrome91-ff89
# This is necessary so Cypress can find Firefox.
options: --user 1001
# This whole block is really only for the Cypress dashboard. It enables
# parallel tests which only make sense if the dashboard is coordinating
# them.
#
# If you don't want to use the Cypress Dashboard, just delete the whole
# strategy section except the browser matrix.
#
# Read more about the parallelization here:
# https://docs.cypress.io/guides/guides/parallelization
strategy:
# When one test fails, DO NOT cancel the other containers, because this
# will kill Cypress processes leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
# fail-fast: false
matrix:
# Setting the different browsers we want to test. This is later used in
# the cypress action.
browser: [chrome, firefox]
# Run copies of the current job in parallel.
# containers: [1, 2]
steps:
- uses: actions/checkout@v3
# Download the build from the previous step.
- uses: actions/download-artifact@v4
with:
name: build
path: build
# Run all cypress tests.
- name: Cypress run
uses: cypress-io/github-action@v5
with:
# Simply start a python http server that exposes the build/ dir
start: python3 -m http.server --directory build 3000
# Only start tests when the server is up and running.
wait-on: http://localhost:3000/
# A simple python http server should really never take longer
# than 10 seconds to start.
wait-on-timeout: 10
browser: ${{ matrix.browser }}
# All these options are for the Cypress Dashboard.
# Remove them if you don't want to use it.
# record: true
# parallel: true
# group: 'UI - ${{ matrix.browser }}'
# Again, these environment variables are only necessary for the
# Cypress Dashboard.
env:
# CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
# Only run if merged to main.
if: github.ref == 'refs/heads/main'
# Only deploy if all tests passed.
needs: [build, test]
runs-on: ubuntu-latest
steps:
# No need to checkout the project, since all we need is to download the
# build artifact from the build step.
- uses: actions/download-artifact@v4
with:
name: build
path: build
# This seems to be the simplest way to publish to a separate branch.
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./build
# Optional. This will create a CNAME file so GitHub Pages serves it
# under this domain.
cname: toitlang.org