Skip to content

Commit 502f00d

Browse files
committed
Create github actions for build, e2e-tests and deploy
1 parent f49f5fe commit 502f00d

File tree

5 files changed

+249
-441
lines changed

5 files changed

+249
-441
lines changed

.github/workflows/build.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
FIREBASE_CONFIG_BASE64:
7+
required: true
8+
9+
jobs:
10+
build:
11+
timeout-minutes: 3
12+
runs-on: ubuntu-latest
13+
container:
14+
image: cypress/browsers:node18.12.0-chrome106-ff106
15+
options: --user 1001
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 18
24+
25+
- name: Cache dependencies
26+
id: cache
27+
uses: actions/cache@v3
28+
with:
29+
path: ./node_modules
30+
key: modules-${{ hashFiles('package-lock.json') }}
31+
32+
- name: Install dependencies
33+
if: steps.cache.outputs.cache-hit != 'true'
34+
run: npm ci
35+
36+
- name: Write Firebase config
37+
run: |
38+
echo ${{ secrets.FIREBASE_CONFIG_BASE64 }} | base64 -d > firebase.config.json
39+
40+
- run: node --version
41+
- run: node -p 'os.cpus()'
42+
- run: npm run build
43+
- run: npm run lint
44+
- run: npm run test:ci
45+
- run: npm run build:test
46+
47+
- name: Save build folder
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: dist
51+
if-no-files-found: error
52+
path: dist
53+
54+
- name: Save test build folder
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: dist-test
58+
if-no-files-found: error
59+
path: dist-test

.github/workflows/deploy.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
isPreview:
7+
required: true
8+
type: boolean
9+
default: false
10+
secrets:
11+
TOKEN:
12+
required: true
13+
FIREBASE_SERVICE_ACCOUNT_LANGUAGES_LEARNER:
14+
required: true
15+
16+
jobs:
17+
deploy_preview_website:
18+
timeout-minutes: 2
19+
environment: ${{ inputs.isPreview && 'deploy_preview' || '' }}
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@main
24+
- name: Download artifact
25+
uses: actions/download-artifact@main
26+
with:
27+
name: dist
28+
path: dist
29+
- uses: FirebaseExtended/action-hosting-deploy@v0
30+
with:
31+
repoToken: "${{ secrets.TOKEN }}"
32+
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_LANGUAGES_LEARNER }}"
33+
expires: ${{ inputs.isPreview && '7d' || '' }}
34+
channelId: ${{ !inputs.isPreview && 'live' || '' }}

.github/workflows/e2e-tests.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: E2E Chrome Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
isManual:
7+
required: false
8+
type: boolean
9+
default: false
10+
platform:
11+
required: true
12+
type: string
13+
secrets:
14+
TEST_USER_USERNAME:
15+
required: true
16+
TEST_USER_PASSWORD:
17+
required: true
18+
19+
jobs:
20+
e2e-chrome-tests:
21+
environment: ${{ inputs.isManual && 'manual_e2e_tests' || '' }}
22+
timeout-minutes: 5
23+
runs-on: ubuntu-latest
24+
container:
25+
image: cypress/browsers:node18.12.0-chrome106-ff106
26+
options: --user 1001
27+
strategy:
28+
fail-fast: false # https://github.com/cypress-io/github-action/issues/48
29+
matrix:
30+
# https://github.com/languages-learner/web/issues/32 - Disable cypress logs because limit reached
31+
# containers: [ 1, 2 ]
32+
containers: [ 1 ]
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 18
41+
42+
- name: Cache dependencies
43+
id: cache
44+
uses: actions/cache@v3
45+
with:
46+
path: ./node_modules
47+
key: modules-${{ hashFiles('package-lock.json') }}
48+
49+
- name: Download the build folders
50+
uses: actions/download-artifact@v4
51+
with:
52+
name: dist-test
53+
path: dist-test
54+
55+
- name: Install dependencies
56+
if: steps.cache.outputs.cache-hit != 'true'
57+
run: npm ci
58+
59+
- name: "Cypress install"
60+
run: yarn cypress install --force
61+
62+
- name: Node info
63+
run: node -v
64+
65+
# - name: __e Dir
66+
# run: ls /__e
67+
68+
- name: "E2E Tests - Chrome"
69+
uses: cypress-io/github-action@v6
70+
with:
71+
install: false
72+
start: npm run preview:test
73+
browser: chrome
74+
# https://github.com/languages-learner/web/issues/32 - Disable cypress logs because limit reached
75+
# record: true
76+
# parallel: true
77+
# group: "E2E - Chrome"
78+
spec: cypress/e2e/*
79+
config-file: ${{ inputs.platform == 'desktop' && 'cypress/configs/preview.ts' || 'cypress/configs/mobile.preview.ts' }}
80+
env:
81+
TEST_USER_USERNAME: ${{ secrets.TEST_USER_USERNAME }}
82+
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
83+
# https://github.com/languages-learner/web/issues/32 - Disable cypress logs because limit reached
84+
# CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
85+
# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
86+
# COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
87+
# COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }}
88+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
90+
- name: Save cypress snapshots
91+
if: always()
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: ${{ inputs.platform == 'desktop' && 'e2e-chrome-cypress-snapshots' || 'e2e-chrome-mobile-cypress-snapshots' }}
95+
path: |
96+
cypress/snapshots/actual
97+
cypress/snapshots/diff

0 commit comments

Comments
 (0)