-
Notifications
You must be signed in to change notification settings - Fork 3.7k
134 lines (124 loc) · 5.13 KB
/
ci-cd.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
name: CI/CD
on:
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
pull_request: # Runs whenever a pull request is created or updated
push: # Runs whenever a commit is pushed to the repository
branches: [master, develop, beta, hotfix/*]
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true
permissions:
contents: write # publish a GitHub release
pages: write # deploy to GitHub Pages
issues: write # comment on released issues
pull-requests: write # comment on released pull requests
jobs:
setup:
runs-on: ubuntu-latest
env:
TRIGGER_DEPLOY: ${{ startsWith(github.ref, 'refs/heads/master') }}
DETECT_CHROMEDRIVER_VERSION: "true"
JEST_JUNIT_OUTPUT_DIR: test-results
NODE_OPTIONS: --max-old-space-size=4000
steps:
- uses: actions/checkout@v4
- uses: wagoid/commitlint-github-action@v5
if: github.event_name == 'pull_request'
- uses: actions/setup-node@v3
with:
cache: "npm"
node-version-file: ".nvmrc"
- name: Info
run: |
cat <<EOF
Node version: $(node --version)
NPM version: $(npm --version)
GitHub ref: ${{ github.ref }}
GitHub head ref: ${{ github.head_ref }}
EOF
- name: Install Chrome Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev libasound2
- name: Install Google Chrome
uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable
id: setup-chrome
- name: Chrome Info
run: |
echo Installed chromium version: ${{ steps.setup-chrome.outputs.chrome-version }}
${{ steps.setup-chrome.outputs.chrome-path }} --version
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# caching node_modules
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci
- name: Lint
run: |
npm run test:lint -- --quiet --output-file test-results/eslint-results.xml --format junit
- name: Store Lint Artifacts
uses: actions/upload-artifact@v3
with:
name: test-output
path: ./test-results/*
test-unit:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "test-unit"
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: |
./node_modules
key: key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
build:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "build"
test-integration:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "test-integration"
# - name: Setup & Test
# run: |
# mkdir -p ./test/results
# npm test
# - name: Generate release version
# run: |
# export RELEASE_TIMESTAMP=$(date +'%Y%m%d%H%M%S')
# export VPKG=$($(npm bin)/json -f package.json version)
# export VERSION=${VPKG}-prerelease.${RELEASE_TIMESTAMP}
# echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_ENV
# if [[ "${GITHUB_REF##*/}" == hotfix/* ]]; then
# echo "NPM_TAG=hotfix" >> $GITHUB_ENV
# else
# echo "NPM_TAG=latest" >> $GITHUB_ENV
# fi
# - name: Build
# run: |
# npm run build
# npm --no-git-tag-version version $RELEASE_VERSION
# - name: Semantic release (configured to run dry if branch is other than 'master')
# env:
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# npx --no -- semantic-release $([[ "$TRIGGER_DEPLOY" == "false" ]] && echo "--dry-run")