-
Notifications
You must be signed in to change notification settings - Fork 118
229 lines (189 loc) · 7.22 KB
/
ci.yaml
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
name: Continuous Integration
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
- edited
jobs:
save-pr:
name: Save PR Number
runs-on: ubuntu-latest
steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
PR_SHA: ${{ github.event.pull_request.head.sha }}
MERGE_SHA: ${{ github.sha }}
run: |
mkdir -p ./pr
echo $PR_NUMBER > ./pr/pr_number
echo $PR_SHA > ./pr/pr_sha
echo $MERGE_SHA > ./pr/merge_sha
- name: Upload PR Number
uses: actions/upload-artifact@v3
with:
name: pr_number
path: pr/
htmlproofer:
name: HTMLProofer
runs-on: ubuntu-latest
steps:
- name: Checkout ARC Repository
uses: actions/checkout@v4
- name: Install OpenSSL
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.0
bundler-cache: true
- name: Build Website
run: |
bundle exec jekyll doctor
bundle exec jekyll build
- name: HTML Proofer
run: bundle exec htmlproofer ./_site --check-html --check-opengraph --report-missing-names --log-level=:debug --assume-extension --empty-alt-ignore --timeframe=6w --disable-external
- name: DNS Validator
run: bundle exec github-pages health-check
codespell:
name: CodeSpell
runs-on: ubuntu-latest
steps:
- name: Checkout ARC Repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- name: Run CodeSpell
uses: codespell-project/actions-codespell@2391250ab05295bddd51e36a8c6295edb6343b0e
with:
check_filenames: true
ignore_words_file: .codespell-whitelist
skip: .git,Gemfile.lock,**/*.png,**/*.gif,**/*.jpg,**/*.svg,.codespell-whitelist,vendor,_site,_config.yml,style.css
only_warn: 1
arcw-validator:
name: ARC Walidator
runs-on: ubuntu-latest
steps:
- name: Checkout ARC Repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- uses: algorandfoundation/arcw-action@dist
id: arcw
with:
token: ${{ secrets.GITHUB_TOKEN }}
unchecked: 0000
check-path:
name: Check for Assets Files
runs-on: ubuntu-latest
outputs:
target_path: ${{ steps.check_new_files.outputs.path }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history to ensure proper branch comparison
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Identify Target Path
id: check_new_files
run: |
# Get the base and head branches
base_branch="${{ github.event.pull_request.base.ref }}"
current_branch="${{ github.event.pull_request.head.ref }}"
# Ensure the base branch is fetched
echo "Fetching base branch: $base_branch"
git fetch origin "$base_branch"
# Ensure we are on the current branch
echo "Switching to current branch: $current_branch"
git checkout "$current_branch"
# Debug: Check if both branches are available
echo "Available branches:"
git branch -a
# Debug: Check git diff output
echo "Git diff output between $base_branch and $current_branch:"
git diff --name-status "origin/$base_branch"
# Extract added or renamed files matching the pattern
file=$(git diff --name-status "origin/$base_branch" | grep -E '^A|R' | sed -n 's/^[A-Z][0-9]*[[:space:]]\+\([^[:space:]]\+\)$/\1/p' | grep -E '^assets/[^/]+/smart_contracts/[^/]+/contract\.py$' | head -n 1)
# Debug: Check filtered file
echo "Filtered file: $file"
# If a match is found, extract the parent directory at the desired level
if [ -n "$file" ]; then
path=$(echo "$file" | sed -E 's|(assets/[^/]+)/.*|\1|')
echo "Found path: $path"
echo "path=$path" >> $GITHUB_ENV
echo "::set-output name=path::$path"
else
echo "No matching files found."
echo "path=" >> $GITHUB_ENV
echo "::set-output name=path::"
fi
shell: bash
validate:
name: Validate
needs: check-path
if: needs.check-path.outputs.target_path != ''
runs-on: ubuntu-latest
steps:
- name: Debug Target Path
run: |
echo "Target path: ${{ needs.check-path.outputs.target_path }}"
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install poetry
run: pipx install poetry
working-directory: ${{ needs.check-path.outputs.target_path }}
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"
- name: Install algokit
run: pipx install algokit
working-directory: ${{ needs.check-path.outputs.target_path }}
- name: Start LocalNet
run: algokit localnet start
working-directory: ${{ needs.check-path.outputs.target_path }}
- name: Bootstrap dependencies
run: algokit project bootstrap all
working-directory: ${{ needs.check-path.outputs.target_path }}
- name: Configure git
shell: bash
run: |
git config --global user.email "actions@github.com"
git config --global user.name "github-actions"
working-directory: ${{ needs.check-path.outputs.target_path }}
- name: Verify .algokit.toml
run: |
if [ -f .algokit.toml ]; then
echo "Found .algokit.toml file. Contents:"
cat .algokit.toml
else
echo "No .algokit.toml file found in the current directory."
fi
working-directory: ${{ needs.check-path.outputs.target_path }}
- name: Audit python dependencies
run: algokit project run audit
working-directory: ${{ needs.check-path.outputs.target_path }}
- name: Lint and format python dependencies
run: algokit project run lint
working-directory: ${{ needs.check-path.outputs.target_path }}
- name: Run tests
shell: bash
run: |
set -o pipefail
algokit project run test
working-directory: ${{ needs.check-path.outputs.target_path }}
- name: Build smart contracts
run: algokit project run build
working-directory: ${{ needs.check-path.outputs.target_path }}
- name: Scan TEAL files for issues
run: algokit project run audit-teal
working-directory: ${{ needs.check-path.outputs.target_path }}
- name: Check output stability of the smart contracts
run: algokit project run ci-teal-diff
working-directory: ${{ needs.check-path.outputs.target_path }}
- name: Run deployer against LocalNet
run: algokit project deploy localnet
working-directory: ${{ needs.check-path.outputs.target_path }}