-
Notifications
You must be signed in to change notification settings - Fork 304
183 lines (167 loc) · 6.73 KB
/
checks.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
name: PR Checks
on:
pull_request:
branches:
- main
# The only commits that will contain changes to the masterlist will be releases
paths-ignore:
- MASTERLIST.md
env:
UPSTREAM_BRANCH: origin/${{ github.base_ref }}
concurrency:
group: pr-${{ github.event.pull_request.number }}-checks
cancel-in-progress: true
jobs:
# ---------- Initial steps ----------
# Check that the changes introduced in this PR include changesets for packages that would need them
check-changesets:
name: Adapter changes accompanied by a changeset
runs-on: ['ubuntu-latest']
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 2
- name: Check whether adapter change also has a changeset
id: adapter_change_has_changeset
run: ./.github/scripts/validate-changesets.sh
# Set up yarn and install dependencies, caching them to be reused across other steps in this workflow
install-packages:
name: Install and verify dependencies
runs-on: [ubuntu-latest]
outputs:
changed-packages: ${{ steps.changed-adapters.outputs.CHANGED_PACKAGES }}
adapter-list: ${{ steps.changed-adapters.outputs.CHANGED_ADAPTERS }}
steps:
- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Set up and install dependencies
uses: ./.github/actions/setup
with:
base-branch: origin/${{ github.base_ref }}
- name: Build list of changed packages and changed adapters
id: changed-adapters
run: ./.github/scripts/changed-adapters.sh
# ---------- Adapter checks (only for changed EAs) ----------
# Run unit tests
unit-tests:
name: Run unit tests for changed adapters
runs-on: [ubuntu-latest]
if: needs.install-packages.outputs.changed-packages != '[]'
needs:
- check-changesets
- install-packages
steps:
- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up and install dependencies
uses: ./.github/actions/setup
- name: Run unit tests
env:
CHANGED_PACKAGES: ${{ needs.install-packages.outputs.changed-packages }}
run: METRICS_ENABLED=false yarn jest --passWithNoTests $(echo $CHANGED_PACKAGES | jq '.[].location + "/test/unit"' -r | tr '\n' ' ')
# Run integration tests
integration-tests:
name: Run integration tests for changed adapters
runs-on: [ubuntu-latest]
if: needs.install-packages.outputs.changed-packages != '[]'
needs:
- check-changesets
- install-packages
steps:
- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up and install dependencies
uses: ./.github/actions/setup
- name: Run integration tests
env:
CHANGED_PACKAGES: ${{ needs.install-packages.outputs.changed-packages }}
run: EA_PORT=0 METRICS_ENABLED=false yarn jest --passWithNoTests $(echo $CHANGED_PACKAGES | jq '.[].location + "/test/integration"' -r | tr '\n' ' ')
# Run linters
linters:
name: Run linters and formatters
runs-on: [ubuntu-latest]
needs:
- check-changesets
- install-packages
steps:
- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up and install dependencies
uses: ./.github/actions/setup
- name: Lint all files
run: yarn lint
- name: Check for formatting errors
run: yarn format:check
# Run documentation tests (check that the doc generation succeeds to avoid problems downstream)
run-documentation-check:
name: Documentation generation test
runs-on: [ubuntu-latest]
if: needs.install-packages.outputs.changed-packages != '[]'
needs:
- check-changesets
- install-packages
env:
METRICS_ENABLED: false
steps:
- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Set up and install dependencies
uses: ./.github/actions/setup
- name: Test Master List Generation
run: yarn generate:master-list -v
- name: Test README Generation
run: yarn generate:readme -v
# Run a script to check that modified v3 adapters have the latest framework version
ea-framework-version-check:
name: Check that changed adapters have the latest EA framework version
runs-on: [ubuntu-latest]
if: needs.install-packages.outputs.changed-packages != '[]'
needs:
- check-changesets
- install-packages
steps:
- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up and install dependencies
uses: ./.github/actions/setup
- name: Check for outdated ea-framework dependencies
env:
CHANGED_PACKAGES: ${{ needs.install-packages.outputs.changed-packages }}
run: |
changed_packages=$(echo $CHANGED_PACKAGES | jq '.[].location' -r | tr '\n' ' ')
dependency="@chainlink/external-adapter-framework"
v3_packages=()
outdated_packages=()
packages=$(find packages -name 'package.json')
latest_version=$(curl -sH "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/smartcontractkit/ea-framework-js/contents/package.json" | jq -r '.content' | base64 -d | jq -r '.version')
# get the list of v3 EAs
for file in $(echo $packages); do
if jq -e ".dependencies[\"$dependency\"]" "$file" >/dev/null; then
v3_packages+=("$(dirname $file)")
fi
done
# check if changed code is part of any v3 EA
for changedFile in $changed_packages; do
for package in "${v3_packages[@]}"; do
if [[ "$changedFile" == "$package"* ]]; then
# found change in v3 EA, comparing versions
local_version=$(jq -r ".dependencies[\"$dependency\"]" "$package/package.json")
if [ "$local_version" != "$latest_version" ] && ! grep -q "^$package$" <<< "${outdated_packages[@]}"; then
outdated_packages+=("$package")
fi
fi
done
done
# print and error if there are outdated adapters
if [ ${#outdated_packages[@]} -gt 0 ]; then
echo "The following packages have an outdated \"$dependency\" dependency:"
for file in "${outdated_packages[@]}"; do
echo "- $file"
done
exit 1
fi