-
Notifications
You must be signed in to change notification settings - Fork 57
211 lines (205 loc) · 6.96 KB
/
build.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: build
on:
pull_request: ~
push:
branches: ['main']
tags: ['v*']
paths-ignore:
- 'docs/**'
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
inputs:
canary-release:
description: 'Release canary version (skips tests and checks)'
type: boolean
required: false
default: false
jobs:
tests:
if: inputs.canary-release == false
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
node-version: [18, 20, 22]
steps:
- uses: actions/checkout@v4
- run: git fetch --depth=1
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn install --frozen-lockfile --ignore-engines
- run: yarn test:unit
env:
SANDBOX_TOKEN: ${{ secrets.API_HUB_SANDBOX_TOKEN }}
- run: yarn test:integration
- run: yarn test:self
- run: yarn test:build-packages
- run: yarn test:type
- if: ${{ github.event_name != 'pull_request' && (failure() || cancelled()) }}
name: Slack Notify
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: SDK Pipeline Bot
SLACK_TITLE: Build tests ${{ job.status }} (${{ matrix.version }})
SLACK_MESSAGE: 'Test failed'
MSG_MINIMAL: event,actions url
SLACK_COLOR: ${{ job.status }}
SLACK_MSG_AUTHOR: ' '
SLACK_ICON: https://sap.github.io/cloud-sdk/img/logo.png
checks:
if: inputs.canary-release == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: git fetch --depth=1
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v4
- run: yarn install --frozen-lockfile --ignore-engines
- run: yarn lint
name: Static Code Check
- run: yarn check:test-service
name: Test Service Version Check
- run: yarn check:dependencies
name: Undeclared dependency Check
- uses: ./.github/actions/check-public-api
with:
force_internal_exports: 'true'
excluded_packages: 'eslint-config, util, test-util'
name: Check public api
- run: yarn test:self
name: Self tests for tools
- run: yarn check:circular
name: Circular dependency Check
- run: yarn doc
name: API Doc Check
- uses: ./.github/actions/check-license
name: License Check
- if: ${{ github.event_name != 'pull_request' && (failure() || cancelled()) }}
name: Slack Notify
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: SDK Pipeline Bot
SLACK_TITLE: Build checks ${{ job.status }} (${{ matrix.version }})
SLACK_MESSAGE: 'Test failed'
MSG_MINIMAL: event,actions url
SLACK_COLOR: ${{ job.status }}
SLACK_MSG_AUTHOR: ' '
SLACK_ICON: https://sap.github.io/cloud-sdk/img/logo.png
e2e-tests:
if: inputs.canary-release == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: git fetch --depth=1
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'
- run: yarn install --frozen-lockfile --ignore-engines
- run: yarn test:e2e
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }}
needs: [tests, checks, e2e-tests]
permissions:
pull-requests: write
contents: write
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
canary-release-pre-check:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
outputs:
skip-release: ${{ steps.date-check.outputs.skip-release }}
needs: [tests, checks, e2e-tests]
steps:
- uses: actions/checkout@v4
- run: git fetch --depth=1
- id: date-check
name: Check if latest commit is within 24 hrs
run: |
lastCommitDate=$(git --no-pager log -n 1 ${{ github.ref_name }} --pretty=format:"%at")
curDate=$(date +%s)
dateDiff=$(expr $curDate - $lastCommitDate)
echo $lastCommitDate, $curDate, $dateDiff
if [[ $dateDiff -gt 86400 ]]
then
echo 'No new commit found on ${{ github.ref }} within the last 24 hrs.'
echo "skip-release=true" >> $GITHUB_OUTPUT
else
echo "skip-release=false" >> $GITHUB_OUTPUT
fi
canary-release:
# execute canary release if:
# either the canary-release was scheduled and the canary-pre-check step resulted in skip-release=false
# or the canary-release input is true
if: always() && (needs.canary-release-pre-check.outputs.skip-release == 'false' || inputs.canary-release == true)
runs-on: ubuntu-latest
needs: [canary-release-pre-check]
steps:
- uses: actions/checkout@v4
- run: git fetch --depth=1
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- run: yarn install --frozen-lockfile --ignore-engines
- name: Canary Release
run: |
date=`date +%Y%m%d%H%M%S`
rm -f .changeset/*.md
cp canary-release-changeset.md .changeset
yarn changeset pre enter ${date}
yarn changeset version
yarn changeset pre exit
yarn changeset publish --tag canary
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }}
draft-github-release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [tests, checks]
steps:
- uses: actions/checkout@v4
- run: git fetch --depth=1
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'
- run: yarn install --frozen-lockfile --ignore-engines
- uses: ./.github/actions/get-changelog
name: Get Changelog
id: get-changelog
- uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
body: ${{ steps.get-changelog.outputs.changelog }}