Repository navigation
138 lines (109 loc) · 3.79 KB
/
Copy pathci.yml
File metadata and controls
138 lines (109 loc) · 3.79 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
135
136
137
138
name: Ember CI
on:
push:
branches: [main, 'release/**']
tags:
- 'v*'
pull_request:
branches: [main, 'release/**']
# Least privilege by default; the publishing jobs opt into what they need.
permissions:
contents: read
# A newer push to the same branch or pull request supersedes the run in flight.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
NODE_VERSION: 22.x
jobs:
test:
name: Lint, test, coverage and build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# `version` is intentionally omitted: pnpm/action-setup reads the pinned
# version from the `packageManager` field in package.json.
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm run lint
# The coverage gate is the thing that proves the coverage number; test it
# before trusting what it reports.
- name: Test the coverage gate
run: pnpm run test:coverage-gate
- name: Run tests with coverage
run: pnpm run coverage
# Uploaded before the gate so a shortfall is still visible on the pull
# request rather than being hidden behind a failed step. The upload is
# reporting, not enforcement: the gate below is what proves coverage, so
# a Codecov outage or rate limit must not fail a build that passed.
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage/lcov.info
flags: fleetops-data
name: fleetops-data
fail_ci_if_error: false
# Forked pull requests cannot read secrets; Codecov accepts tokenless
# uploads from public repositories, so this is empty rather than absent.
token: ${{ secrets.CODECOV_TOKEN }}
- name: Enforce 100% coverage
run: pnpm run coverage:check
- name: Build
run: pnpm run build
npm_publish:
name: Publish to npm
needs: test
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
- name: Set up npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc
- name: Publish
run: npm publish --access public
github_publish:
name: Publish to GitHub Packages
needs: test
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
- name: Configure npm for GitHub registry
run: |
echo "@fleetbase:registry=https://npm.pkg.github.com/" >> ~/.npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc
- name: Publish to GitHub registry
run: npm publish