-
-
Notifications
You must be signed in to change notification settings - Fork 675
134 lines (115 loc) · 3.83 KB
/
check.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: check
on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
version:
name: Ensure package version match
if: startsWith(github.ref_name, 'v')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check Git tag format
run: |
_tag="${{ github.ref_name }}"
if ! printf "%s\n" "$_tag" | grep -q -P '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(alpha|beta|rc)\.(0|[1-9][0-9]*))?$'; then
printf '[ERROR]: Git tag (%s) wrong format\n' "$_tag"
exit 1
fi
- name: Read package.json version
uses: sergeysova/jq-action@v2
id: version_package
with:
cmd: jq --raw-output .version package.json
- name: Read GitHub version
uses: pozetroninc/github-action-get-latest-release@master
id: version_v_github
with:
owner: MichalLytek
repo: type-graphql
excludes: prerelease, draft
- name: Remove leading v* from GitHub version
id: version_github
run: |
_version="${{ steps.version_v_github.outputs.release }}"
printf 'value=%s\n' "${_version#?}" >> "$GITHUB_OUTPUT"
- name: Read Git tag version
id: version_gittag
run: |
_version="${{ github.ref_name }}"
printf 'value=%s\n' "${_version#?}" >> "$GITHUB_OUTPUT"
- name: Compare package.json with Git tag
uses: madhead/semver-utils@latest
id: comparison_package_gittag
with:
version: ${{ steps.version_package.outputs.value }}
compare-to: ${{ steps.version_gittag.outputs.value }}
lenient: false
- name: Compare Git tag with GitHub
uses: madhead/semver-utils@latest
id: comparison_gittag_github
with:
version: ${{ steps.version_gittag.outputs.value }}
compare-to: ${{ steps.version_github.outputs.value }}
lenient: false
- name: Check package.json == Git tag
run: |
if [ ! "${{ steps.comparison_package_gittag.outputs.comparison-result }}" = "=" ]; then
printf '[ERROR]: package.json (%s) != Git tag (%s)\n' "${{ steps.version_package.outputs.value }}" "${{ steps.version_gittag.outputs.value }}"
exit 1
fi
- name: Check Git tag > GitHub
run: |
if [ ! "${{ steps.comparison_gittag_github.outputs.comparison-result }}" = ">" ]; then
printf '[ERROR]: Git tag (%s) !> GitHub (%s)\n' "${{ steps.version_gittag.outputs.value }}" "${{ steps.version_github.outputs.value }}"
exit 1
fi
check:
name: Build & Lint & Test
needs: version
if: always() && (needs.version.result == 'success' || needs.version.result == 'skipped')
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node-version: [16.x, 18.x, 20.x]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: |
npm ci
- name: Build
run: |
npm run build
npm run build:benchmarks
- name: Check
run: |
npm run check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test
run: npm run test:ci
env:
CI: true
- name: Upload code coverage
uses: codecov/codecov-action@v3
if: matrix.node-version == '18.x'