-
Notifications
You must be signed in to change notification settings - Fork 8
72 lines (64 loc) · 2.41 KB
/
validate.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
# PR's only
name: Validate
on:
pull_request:
branches: [main]
env:
FORCE_COLOR: 1
jobs:
linuxNode16:
name: '[Linux] Node.js v16: Lint, Formatting, Eventual Commitlint, Eventual Changelog'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# For commitlint purpose ensure to have complete list of PR commits
# It's loose and imperfect assumption that PR has no more than 30 commits
fetch-depth: 30
- name: Retrieve last main commit (for `git diff` purposes)
run: |
git checkout -b pr
git fetch --prune --depth=30 origin +refs/heads/main:refs/remotes/origin/main
git checkout main
git checkout pr
- name: Retrieve ~/.npm from cache
uses: actions/cache@v1
with:
path: ~/.npm
key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-v16-${{ runner.os }}-${{ github.ref }}-
npm-v16-${{ runner.os }}-refs/heads/main-
- name: Retrieve node_modules from cache
id: cacheNodeModules
uses: actions/cache@v1
with:
path: node_modules
key: node-modules-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: |
node-modules-v16-${{ runner.os }}-${{ github.ref }}-
node-modules-v16-${{ runner.os }}-refs/heads/main-
- name: Install Node.js and npm
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: Install dependencies
if: steps.cacheNodeModules.outputs.cache-hit != 'true'
run: |
npm update --no-save
npm update --save-dev --no-save
- name: Validate Prettier formatting
run: npm run prettier-check:updated
- name: Validate ESLint rules
run: npm run lint:updated
- name: Validate Commit messages
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
run: npx commitlint -f main
- name: Validate changelog (if new version)
run: |
NEW_VERSION=`git diff -U0 main package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || :
if [ -n "$NEW_VERSION" ];
then
npx dump-release-notes-from-cc-changelog $NEW_VERSION
fi