-
-
Notifications
You must be signed in to change notification settings - Fork 677
148 lines (129 loc) · 4.42 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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
env:
TYPE_GRAPHQL_REF_NAME: ${{ github.ref_name }}
run: |
_tag="$TYPE_GRAPHQL_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
env:
TYPE_GRAPHQL_VERSION: ${{ steps.version_v_github.outputs.release }}
run: |
_version="$TYPE_GRAPHQL_VERSION"
printf 'value=%s\n' "${_version#?}" >> "$GITHUB_OUTPUT"
- name: Read Git tag version
id: version_gittag
env:
TYPE_GRAPHQL_REF_NAME: ${{ github.ref_name }}
run: |
_version="$TYPE_GRAPHQL_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
env:
TYPE_GRAPHQL_COMPARISON: ${{ steps.comparison_package_gittag.outputs.comparison-result }}
TYPE_GRAPHQL_VERSION_PACKAGE: ${{ steps.version_package.outputs.value }}
TYPE_GRAPHQL_VERSION_TAG: ${{ steps.version_gittag.outputs.value }}
run: |
if [ ! "$TYPE_GRAPHQL_COMPARISON" = "=" ]; then
printf '[ERROR]: package.json (%s) != Git tag (%s)\n' "$TYPE_GRAPHQL_VERSION_PACKAGE" "$TYPE_GRAPHQL_VERSION_TAG"
exit 1
fi
- name: Check Git tag > GitHub
env:
TYPE_GRAPHQL_COMPARISON: ${{ steps.comparison_gittag_github.outputs.comparison-result }}
TYPE_GRAPHQL_VERSION_TAG: ${{ steps.version_gittag.outputs.value }}
TYPE_GRAPHQL_VERSION_GITHUB: ${{ steps.version_github.outputs.value }}
run: |
if [ ! "$TYPE_GRAPHQL_COMPARISON" = ">" ]; then
printf '[ERROR]: Git tag (%s) !> GitHub (%s)\n' "$TYPE_GRAPHQL_VERSION_TAG" "$TYPE_GRAPHQL_VERSION_GITHUB"
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: [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@v4
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@v4
if: matrix.node-version == '20.x'