-
Notifications
You must be signed in to change notification settings - Fork 192
Expand file tree
/
Copy pathreusable-run-linting-check-and-unit-tests.yml
More file actions
144 lines (140 loc) · 4.28 KB
/
reusable-run-linting-check-and-unit-tests.yml
File metadata and controls
144 lines (140 loc) · 4.28 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
139
140
141
142
143
144
name: Run unit tests
#
# PROCESS
#
# 1. Checkout code
# 2. Install dependencies & build project
# 3. Run linting
# 4. Run unit tests
#
# NOTES
# We create different jobs for different workspaces of the monorepo, since we have slightly different requirements for each.
# For example, the docs (`check-docs`), runs markdown linting, while the layer (`check-layer-publisher`), examples (`check-examples`),
# and code snippets (`check-docs-snippets`) jobs run linting and unit tests but only for the current LTS version of Node.js.
#
# For the Powertools for AWS main features (aka `packages/*`), instead we run linting and unit tests for all the supported
# versions of Node.js.
#
# Since #2938, we are in the process of improving our test suite, so we are gradually extracting the tests for each package
# from (`run-linting-check-and-unit-tests-on-utilities`) to their own job, so we can run them in parallel using the matrix
# strategy and reduce the time it takes to run the tests, as well as improve maintainer experience in case of failures.
#
# USAGE
#
# NOTE: meant to be called by ./.github/workflows/pr-run-linting-check-and-unit-tests.yml when a PR is opened or updated,
# or by ./.github/workflows/make-release.yml when a release is made.
#
on:
workflow_call:
permissions: {}
jobs:
code-quality:
permissions:
contents: read
runs-on: ubuntu-latest
env:
NODE_ENV: dev
strategy:
matrix:
version: [22, 24]
workspace: [
"packages/batch",
"packages/commons",
"packages/event-handler",
"packages/idempotency",
"packages/jmespath",
"packages/logger",
"packages/tracer",
"packages/parser",
"packages/parameters",
"packages/validation",
"packages/metrics",
"packages/kafka"
]
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup NodeJS
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.version }}
cache: "npm"
- name: Setup dependencies
uses: aws-powertools/actions/.github/actions/cached-node-modules@29979bc5339bf54f76a11ac36ff67701986bb0f0
with:
nodeVersion: ${{ matrix.version }}
- name: Linting
run: npm run lint -w ${{ matrix.workspace }}
- name: Unit tests
run: |
npm run test:unit:coverage -w ${{ matrix.workspace }}
npm run test:unit:types -w ${{ matrix.workspace }}
check-examples:
permissions:
contents: read
runs-on: ubuntu-latest
env:
NODE_ENV: dev
strategy:
matrix:
example: ["app"]
fail-fast: false
defaults:
run:
working-directory: examples/${{ matrix.example }}
steps:
- &checkout_code
name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- &setup_node
name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
cache: "npm"
- &setup_dependencies
name: Setup dependencies
uses: aws-powertools/actions/.github/actions/cached-node-modules@29979bc5339bf54f76a11ac36ff67701986bb0f0
- name: Run linting
run: npm run lint:ci
- name: Run tests
run: npm t
check-layer-publisher:
permissions:
contents: read
runs-on: ubuntu-latest
env:
NODE_ENV: dev
steps:
- *checkout_code
- *setup_node
- *setup_dependencies
- name: Run linting
run: npm run lint:ci -w layers
- name: Run tests
run: npm run test:unit -w layers
check-docs-snippets:
permissions:
contents: read
runs-on: ubuntu-latest
env:
NODE_ENV: dev
steps:
- *checkout_code
- *setup_node
- *setup_dependencies
- name: Run linting
run: npm run lint:ci -w examples/snippets
check-docs:
permissions:
contents: read
runs-on: ubuntu-latest
env:
NODE_ENV: dev
steps:
- *checkout_code
- *setup_node
- *setup_dependencies
- name: Run linting
run: npm run lint:markdown