-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (80 loc) · 2.46 KB
/
node.js.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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Test and lint
on:
push:
branches: [ "main", "v[0-9]+.[0-9]+.x", "v[0-9]+.x" ]
pull_request:
branches: [ "main", "v[0-9]+.[0-9]+.x", "v[0-9]+.x" ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
- run: npm ci
# Set up SSH access, as the test suite needs to be able to access git
# repos to validate functionality.
- name: Decrypt secrets
env:
PASSWORD: ${{ secrets.SSH_ENCRYPTION_KEY }}
run: |
gpg --batch --passphrase $PASSWORD --output .github/workflows/secrets/id_ed25519 --decrypt .github/workflows/secrets/id_ed25519.enc
- name: Setup SSH agent
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
chmod 0600 .github/workflows/secrets/id_ed25519
ssh-add .github/workflows/secrets/id_ed25519
- name: Set up git config
run: |
git config --global user.name "MadGutsBot"
git config --global user.email "[email protected]"
- name: Set up .env
run: cp .env.example .env
- name: Run test suite
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: npm test
- name: Show server output
if: always()
run: cat server.log
- name: Cleanup SSH Agent
if: always()
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh-add -D
rm -Rf ~/.ssh
rm .github/workflows/secrets/id_ed25519
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
- run: npm ci
- name: Run linting
run: npm run lint
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
- run: npm ci
- name: Run type-checking
run: npm run check