-
Notifications
You must be signed in to change notification settings - Fork 27
134 lines (127 loc) · 6.01 KB
/
build-test.js.yml
File metadata and controls
134 lines (127 loc) · 6.01 KB
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
# This workflow builds the project and executes all tests on the main branch or PRs.
name: Build and test
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
merge_group:
# Cancel previous PR/branch runs when a new commit is pushed
concurrency:
group: ${{ github.ref }}-build-tests
cancel-in-progress: true
jobs:
check-and-lint:
outputs:
package-changes: ${{ steps.changes.outputs.src }}
docker-changes: ${{ steps.changes.outputs.docker }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v4
id: changes
if: github.event.pull_request.user.login != 'dependabot[bot]'
with:
filters: |
src:
- "package.json"
- "packages/**/package.json"
- ".github/workflows/build-test.js.yml"
docker:
- "package.json"
- "package-lock.json"
- "packages/**"
- "docker/**"
- ".github/workflows/build-test.js.yml"
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
- run: npm run format-verify
- run: npm run lint
build-non-linux:
needs: [check-and-lint]
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [22.x, 24.x, 26.x]
os: [macos-latest, windows-latest]
steps:
- uses: actions/checkout@v6
if: needs.check-and-lint.outputs.package-changes == 'true' || github.event.pull_request.user.login == 'dependabot[bot]'
- uses: actions/setup-python@v6
if: needs.check-and-lint.outputs.package-changes == 'true' || github.event.pull_request.user.login == 'dependabot[bot]'
# needed as long as we test Node.js 16 and npm <10.2.2 is used for Node.js 18/20
with:
python-version: "3.11"
- name: Build on ${{ matrix.os }}
if: needs.check-and-lint.outputs.package-changes == 'true' || github.event.pull_request.user.login == 'dependabot[bot]'
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
os: ${{ matrix.os }}
test:
needs: [check-and-lint]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x, 24.x, 26.x]
steps:
- uses: actions/checkout@v6
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
- name: Execute tests
run: npm run test
docker-build:
# Builds the dev image from source (scripts enabled) so native module
# compilation and the Dockerfile itself are exercised on every relevant PR,
# instead of only at release time. The build is cached (gha) so the
# docker-integration-test job reuses it without rebuilding from scratch.
needs: [check-and-lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
if: needs.check-and-lint.outputs.docker-changes == 'true' || github.event.pull_request.user.login == 'dependabot[bot]'
- name: Set up Docker Buildx
if: needs.check-and-lint.outputs.docker-changes == 'true' || github.event.pull_request.user.login == 'dependabot[bot]'
uses: docker/setup-buildx-action@v4
- name: Build dev image from source
if: needs.check-and-lint.outputs.docker-changes == 'true' || github.event.pull_request.user.login == 'dependabot[bot]'
uses: docker/build-push-action@v7
with:
context: .
file: ./docker/matterjs-server/Dockerfile.dev
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
docker-integration-test:
# Runs the integration suite with the matter-server inside the dev image
# (restored from the gha cache populated by docker-build), proving the
# shipped container actually runs — not just that it builds.
needs: [check-and-lint, docker-build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
if: needs.check-and-lint.outputs.docker-changes == 'true' || github.event.pull_request.user.login == 'dependabot[bot]'
- name: Set up Docker Buildx
if: needs.check-and-lint.outputs.docker-changes == 'true' || github.event.pull_request.user.login == 'dependabot[bot]'
uses: docker/setup-buildx-action@v4
- name: Restore dev image from cache
if: needs.check-and-lint.outputs.docker-changes == 'true' || github.event.pull_request.user.login == 'dependabot[bot]'
uses: docker/build-push-action@v7
with:
context: .
file: ./docker/matterjs-server/Dockerfile.dev
push: false
load: true
tags: matterjs-server:ci
cache-from: type=gha
- name: Prepare host testing environment
if: needs.check-and-lint.outputs.docker-changes == 'true' || github.event.pull_request.user.login == 'dependabot[bot]'
uses: ./.github/actions/prepare-env
- name: Run integration tests against server in Docker
if: needs.check-and-lint.outputs.docker-changes == 'true' || github.event.pull_request.user.login == 'dependabot[bot]'
env:
MATTER_TEST_SERVER_MODE: docker
MATTER_TEST_DOCKER_IMAGE: matterjs-server:ci
run: npx matter-test esm --prefix packages/matter-server --spec ./test/IntegrationTest.ts