Skip to content

Commit e66563c

Browse files
authored
fix: Fixes lychee version and adds CICD support (#295)
* fix: Fixes lychee version and adds CICD support - Fix pre-commit autoupdate reverting lychee to mutable 'nightly' ref - Exclude lychee from Makefile and CI autoupdate (non-standard tags) - Add .secrets support for ACT GitHub token authentication - Update developer docs with pre-commit hooks and ACT setup guide * fix: lychee execution in the GitHub Action has errors Those errors are ``` ## Errors per input ### Errors in docs/Bitvavo.md * [403] <https://bitvavo.com/en/> | Rejected status code (this depends on your "accept" configuration): Forbidden * [403] <https://bitvavo.com/en/markets> | Rejected status code (this depends on your "accept" configuration): Forbidden * [403] <https://support.bitvavo.com/hc/en-us> | Rejected status code (this depends on your "accept" configuration): Forbidden ### Errors in docs/DEGIRO.md * [503] <https://www.degiro.com/> | Rejected status code (this depends on your "accept" configuration): Service Unavailable * [503] <https://www.degiro.nl/helpdesk/> | Rejected status code (this depends on your "accept" configuration): Service Unavailable ``` But those work locally. The issue may be due to rate limiting or network restrictions. We will ignore it so far and look into detail in the future.
1 parent d4eecb6 commit e66563c

File tree

7 files changed

+143
-7
lines changed

7 files changed

+143
-7
lines changed

.github/workflows/cicd.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ jobs:
2323
- name: Markdown Check
2424
run: |
2525
make markdown-check
26+
- name: Check links in Markdown files
27+
if: ${{ !env.ACT }}
28+
uses: lycheeverse/lychee-action@v2
29+
with:
30+
args: --config lychee.toml README.md CHANGELOG.md docs/
31+
fail: false # Don't fail build on broken links (external sites can be flaky)
2632

2733
test:
2834
name: Tests

.github/workflows/precommit-autoupdate.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ jobs:
1919
- name: Install pre-commit
2020
run: pip install pre-commit
2121
- name: Run pre-commit autoupdate script
22-
run: pre-commit autoupdate
22+
run: |
23+
# Run autoupdate but exclude lychee (uses non-standard tag format)
24+
pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks
25+
pre-commit autoupdate --repo https://github.com/astral-sh/ruff-pre-commit
2326
- name: Check for changes
2427
id: check-changes
2528
run: |

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ config/*
6969

7070
# nektos/act
7171
.actrc
72+
# ACT secrets
73+
.secrets
7274

7375
# lycheecache (Markdown Link Checker)
7476
.lycheecache

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ repos:
3737
stages: [pre-commit]
3838

3939
- repo: https://github.com/lycheeverse/lychee
40-
rev: nightly
40+
rev: lychee-v0.22.0 # Not auto-updated
4141
hooks:
4242
- id: lychee
4343
name: Check Markdown Links

.secrets.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# ACT secrets file
2+
# Copy this file to .secrets and fill in your GitHub Personal Access Token
3+
# Generate a token at: https://github.com/settings/tokens
4+
# Required scope: public_repo (for public repositories)
5+
GITHUB_TOKEN=your_github_token_here

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,20 +374,28 @@ pre-commit-run: ## Run pre-commit hooks on all files
374374

375375
pre-commit-update: ## Update pre-commit hook versions
376376
@echo -e "$(BOLD)$(YELLOW)Updating pre-commit hooks...$(RESET)"
377-
poetry run pre-commit autoupdate
377+
@echo -e "$(BOLD)$(BLUE)Note: Excluding lychee (uses non-standard tag format)$(RESET)"
378+
poetry run pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks
379+
poetry run pre-commit autoupdate --repo https://github.com/astral-sh/ruff-pre-commit
378380

379381
#==============================================================================
380382
##@ CI/CD Operations
381383
#==============================================================================
382384

383385
cicd: _check-docker _check-act ## Run CI/CD pipeline (use job=<name> or workflow=<name>)
384386
@echo -e "$(BOLD)$(BLUE)Running CI/CD pipeline...$(RESET)"
385-
@if [ -n "$(workflow)" ]; then \
387+
@ACT_SECRETS=""; \
388+
if [ -f .secrets ]; then \
389+
ACT_SECRETS="--secret-file .secrets"; \
390+
else \
391+
echo -e "$(YELLOW)Warning: .secrets file not found. Create one from .secrets.example for GitHub Actions to work.$(RESET)"; \
392+
fi; \
393+
if [ -n "$(workflow)" ]; then \
386394
echo -e "$(YELLOW)Running workflow: $(workflow)$(RESET)"; \
387-
act -W "$(WORKFLOWS_DIR)/$(workflow).yml" --container-architecture $(ACT_ARCH) -P $(ACT_PLATFORM); \
395+
act -W "$(WORKFLOWS_DIR)/$(workflow).yml" --container-architecture $(ACT_ARCH) -P $(ACT_PLATFORM) $$ACT_SECRETS; \
388396
elif [ -n "$(job)" ]; then \
389397
echo -e "$(YELLOW)Running job: $(job)$(RESET)"; \
390-
act --job $(job) --container-architecture $(ACT_ARCH) -P $(ACT_PLATFORM); \
398+
act --job $(job) --container-architecture $(ACT_ARCH) -P $(ACT_PLATFORM) $$ACT_SECRETS; \
391399
else \
392400
echo -e "$(YELLOW)Available jobs and workflows:$(RESET)"; \
393401
act --list --container-architecture $(ACT_ARCH); \

docs/Developing-Stonks-Overwatch.md

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,39 @@ These commands will check the code linting or do the best effort to properly for
142142
Make sure to execute `make pre-commit-install` to install the pre-commit hooks, so the code is automatically checked
143143
before committing.
144144

145+
#### Pre-commit Hooks
146+
147+
The project uses pre-commit hooks to maintain code quality. The hooks include:
148+
149+
- Code formatting (Ruff)
150+
- Python linting (Ruff)
151+
- YAML validation
152+
- Markdown linting
153+
- Link checking (Lychee)
154+
- Poetry validation
155+
- Django system checks
156+
- Test execution
157+
158+
**Installing hooks:**
159+
160+
```shell
161+
make pre-commit-install
162+
```
163+
164+
**Running hooks manually:**
165+
166+
```shell
167+
make pre-commit-run
168+
```
169+
170+
**Updating hook versions:**
171+
172+
```shell
173+
make pre-commit-update
174+
```
175+
176+
> **Note on Lychee**: The link checker (Lychee) uses a non-standard tag format (`lychee-vX.Y.Z`) which is excluded from automatic updates. The `make pre-commit-update` command only updates the `pre-commit-hooks` and `ruff-pre-commit` repositories to prevent reverting Lychee to a mutable `nightly` branch reference. If you need to update Lychee, manually edit `.pre-commit-config.yaml` and change the `rev` to the desired stable tag (e.g., `lychee-v0.22.0`).
177+
145178
### Test
146179

147180
```shell
@@ -202,7 +235,86 @@ As before, only the application for the current OS will be created and executed.
202235
make cicd
203236
```
204237
205-
Will execute the GitHub Actions locally. It's a good way of validating changes in the CI/CD code
238+
Will execute the GitHub Actions locally using [ACT](https://github.com/nektos/act). It's a good way of validating changes in the CI/CD code before pushing to GitHub.
239+
240+
#### Setting up ACT for Local CI/CD Testing
241+
242+
ACT requires a GitHub Personal Access Token to clone GitHub Actions (like `actions/setup-python`, `actions/cache`, etc.).
243+
244+
**Initial Setup:**
245+
246+
1. **Create a GitHub Personal Access Token:**
247+
- Go to: [https://github.com/settings/tokens/new](https://github.com/settings/tokens/new)
248+
- Token name: "ACT Local Testing"
249+
- Expiration: Your choice (90 days recommended)
250+
- Select scopes: Check **"public_repo"** (for public repositories)
251+
- Click "Generate token"
252+
- Copy the token (you won't see it again!)
253+
254+
2. **Create `.secrets` file:**
255+
256+
```shell
257+
cp .secrets.example .secrets
258+
```
259+
260+
3. **Edit `.secrets` and add your token:**
261+
262+
```bash
263+
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
264+
```
265+
266+
Replace `ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx` with your actual token.
267+
268+
4. **Test it:**
269+
270+
```shell
271+
make cicd job=lint
272+
```
273+
274+
> **Security Note**: The `.secrets` file is already in `.gitignore` and will never be committed to the repository.
275+
276+
**Running Specific Jobs:**
277+
278+
```shell
279+
# Run the lint job
280+
make cicd job=lint
281+
282+
# Run the test job
283+
make cicd job=test
284+
285+
# List all available jobs
286+
make cicd
287+
```
288+
289+
**Running Specific Workflows:**
290+
291+
```shell
292+
# Run the entire CI/CD workflow
293+
make cicd workflow=cicd
294+
295+
# Run the pre-commit autoupdate workflow
296+
make cicd workflow=precommit-autoupdate
297+
```
298+
299+
**Troubleshooting ACT:**
300+
301+
If you see authentication errors like `authentication required: Invalid username or token`, ensure:
302+
- Your `.secrets` file exists and contains a valid `GITHUB_TOKEN`
303+
- The token has the `public_repo` scope enabled
304+
- You've copied the token correctly (no extra spaces or newlines)
305+
306+
**Note on Lychee Link Checking:**
307+
The link checking step (lychee) is automatically skipped when running with ACT due to architecture compatibility issues (ARM64 vs x86_64). The lychee check will still run in the actual GitHub Actions environment. You can verify links locally by running:
308+
309+
```shell
310+
make markdown-links-check
311+
```
312+
313+
Or through pre-commit hooks:
314+
315+
```shell
316+
make pre-commit-run
317+
```
206318
207319
## Troubleshooting
208320

0 commit comments

Comments
 (0)