-
-
Notifications
You must be signed in to change notification settings - Fork 50
72 lines (63 loc) · 2.57 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
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
pull_request:
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-22.04
# do a matrix test with different node versions
strategy:
fail-fast: false
matrix:
node-version: [16.x, 18.x, 20.x, 21.x]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# try to perform a nodejs setup
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
# docker test
- name: install+run docker-unifi-controller
run: |
# create docker-unifi-controller
docker create --name=unifi-controller -e PUID=1001 -e PGID=116 -e MEM_LIMIT=1024 -e MEM_STARTUP=1024 -e TZ=Etc/UTC -p 8443:8443 -p 8080:8080 -v $GITHUB_WORKSPACE/unifi-storage:/config lscr.io/linuxserver/unifi-controller:latest
# do an initial startup to create databse&co
docker start unifi-controller
sleep 10
# stop the unifi-controller right away and
# install our own demo database instead
docker stop unifi-controller
sudo rm -rf unifi-storage/data
sudo tar -C unifi-storage -xf $GITHUB_WORKSPACE/.github/workflows/db-demo-dump.tar.bz2
# final unifi-controller startup
docker start unifi-controller
# wait for unifi-controller to be ready
while ! curl -ks https://127.0.0.1:8443; do echo waiting for unifi-controller; ((c++)) && ((c==10)) && break; sleep 3; done
# wait some more time to let the unifi network app settle
sleep 20
# remote debug tmate session
- name: debug tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
# run npm tests
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm test
env:
CI: true