Compare commits

30 Commits
Author SHA1 Message Date
nvidia-stock-bot-ci 80731ea2e1 Bump build version to 4.1.5 [skip ci] 2026-11-28 04:17:10 +00:00
Boteex Bot a905be10bc Pin python Docker tag to 0f9552b (#42)
CI / build-and-scan (push) Successful in 49s
2026-11-28 05:05:16 +01:00
Djeex b4e712f3ac Use the shared cicdeex actions (#41)
CI / build-and-scan (push) Successful in 37s
Co-authored-by: Djeex <[email protected]>
2026-11-22 13:20:38 +01:00
Djeex 32c97d9173 Merge pull request 'Run the weekly scan on Saturday' (#40) from ci-align into main
CI / build-and-scan (push) Successful in 1m48s
2026-11-21 23:48:42 +01:00
Djeex a652900b9e Run the weekly scan on Saturday
CI / build-and-scan (pull_request) Successful in 29s
2026-11-21 22:31:35 +00:00
Djeex 556ac0ba21 Merge pull request 'Use the shared Renovate preset' (#39) from renovate-preset into main
CI / build-and-scan (push) Successful in 31s
2026-11-21 22:12:45 +01:00
Djeex c709e8d960 Use the shared Renovate preset
CI / build-and-scan (pull_request) Successful in 41s
2026-11-21 20:56:56 +00:00
Djeex 302f6f9f95 Update aquasec/trivy Docker tag to v0.76.2 (#38)
CI / build-and-scan (push) Successful in 1m38s
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [aquasec/trivy](https://www.aquasec.com/products/trivy/) ([source](https://github.com/aquasecurity/trivy)) | minor | `0.74.0` → `0.76.2` |

---

### Release Notes

<details>
<summary>aquasecurity/trivy (aquasec/trivy)</summary>

### [`v0.76.2`](https://github.com/aquasecurity/trivy/releases/tag/v0.76.2)

[Compare Source](https://github.com/aquasecurity/trivy/compare/v0.76.1...v0.76.2)

#### 🔐 Security update 🛡️

Trivy v0.76.2 bundles several security fixes:

- Official container images are rebuilt on Alpine 3.24.3, which fixes `musl`/`musl-utils` (CVE-2026-107891), and the build picks up fixed `libcurl` (24 CVEs, including HIGH CVE-2026-92392) and `brotli-libs` (CVE-2026-111497) from the `v3.24` package repository.
- `golang.org/x/net` is bumped to v0.62.0, fixing two vulnerabilities in `golang.org/x/net/html`: CVE-2026-78661 (quadratic complexity when coalescing text nodes) and CVE-2026-97045 (missing ancestor namespace check when rendering raw text).
- `github.com/go-jose/go-jose/v4` is bumped to v4.1.6, fixing [GHSA-mgcc-cww5-fp2q](https://github.com/go-jose/go-jose/security/advisories/GHSA-mgcc-cww5-fp2q).

We recommend upgrading to v0.76.2 and redeploying container images to apply these updates.

#### Changelog

- [`3f6334d`](https://github.com/aquasecurity/trivy/commit/3f6334d223b52188324af3b9923b4249cd206652) release: v0.76.2 \[release/v0.76] ([#&#8203;11552](https://github.com/aquasecurity/trivy/issues/11552))
- [`1cabe83`](https://github.com/aquasecurity/trivy/commit/1cabe83c11ffed6e984ab46be8886e1e01516ead) fix(deps): bump golang.org/x/net from 0.61.0 to 0.62.0 \[backport: release/v0.76] ([#&#8203;11554](https://github.com/aquasecurity/trivy/issues/11554))
- [`be08de4`](https://github.com/aquasecurity/trivy/commit/be08de47d0d76fca7e992c0f47fbcf7853f8a713) chore(deps): bump the common group across 1 directory with 14 updates \[backport: release/v0.76] ([#&#8203;11555](https://github.com/aquasecurity/trivy/issues/11555))
- [`a8537d3`](https://github.com/aquasecurity/trivy/commit/a8537d389cbd0fa215eddfddc27150fc7bc82a6c) fix(deps): bump github.com/go-jose/go-jose/v4 from 4.1.5 to 4.1.6 \[backport: release/v0.76] ([#&#8203;11553](https://github.com/aquasecurity/trivy/issues/11553))
- [`ae26b88`](https://github.com/aquasecurity/trivy/commit/ae26b88c3b3c380808e767dfb63f9b8dcd5f64fd) fix(deps): bump alpine to 3.24.3 in container images \[backport: release/v0.76] ([#&#8203;11551](https://github.com/aquasecurity/trivy/issues/11551))

### [`v0.76.1`](https://github.com/aquasecurity/trivy/releases/tag/v0.76.1)

[Compare Source](https://github.com/aquasecurity/trivy/compare/v0.76.0...v0.76.1)

#### 🔐 Security update: eMudhra CA incident 🛡️

Trivy v0.76.1 includes mitigations for the [eMudhra intermediate CA key compromise](https://blog.cloudflare.com/emudhra-certificate-compromise/).

- Official binaries are built with Go 1.27.3, which includes the certificate distrust mitigation tracked as [CVE-2026-111943](https://go.dev/issue/82345).
- Official container images include an updated Alpine CA trust store that rejects the affected certificate chains.

We recommend upgrading to v0.76.1 and redeploying container images to apply these updates. If you build Trivy from source, use Go 1.27.3 or later and keep your runtime CA trust store up to date.

#### Changelog

- [`e713f67`](https://github.com/aquasecurity/trivy/commit/e713f67f7d54decdcd9b3132c9751833dcced698) release: v0.76.1 \[release/v0.76] ([#&#8203;11445](https://github.com/aquasecurity/trivy/issues/11445))
- [`6647bd6`](https://github.com/aquasecurity/trivy/commit/6647bd6ec5924087956285b773b8cae10508736e) fix(deps): bump the aws group across 1 directory with 6 updates \[backport: release/v0.76] ([#&#8203;11446](https://github.com/aquasecurity/trivy/issues/11446))
- [`e0964c9`](https://github.com/aquasecurity/trivy/commit/e0964c97819b1d6a45b7e0426803745f173fc550) fix(deps): bump the docker group with 3 updates \[backport: release/v0.76] ([#&#8203;11443](https://github.com/aquasecurity/trivy/issues/11443))
- [`992c360`](https://github.com/aquasecurity/trivy/commit/992c360c33d9f9627bb24c1fe3f20815110c88e5) fix(deps): bump the common group with 3 updates \[backport: release/v0.76] ([#&#8203;11442](https://github.com/aquasecurity/trivy/issues/11442))

### [`v0.76.0`](https://github.com/aquasecurity/trivy/blob/HEAD/CHANGELOG.md#0760-2026-10-14)

[Compare Source](https://github.com/aquasecurity/trivy/compare/v0.75.0...v0.76.0)

##### Features

- **crypto:** distinguish DSA algorithms by L and N ([#&#8203;11366](https://github.com/aquasecurity/trivy/issues/11366)) ([bcc9bd4](https://github.com/aquasecurity/trivy/commit/bcc9bd47fa67dd251312d0b361fa568a108f0cac))
- **crypto:** report nominal security levels of algorithms ([#&#8203;11369](https://github.com/aquasecurity/trivy/issues/11369)) ([a67baa8](https://github.com/aquasecurity/trivy/commit/a67baa8d36f5307d5f9fbdfd9bc9977bf74228a7))
- **echo:** support Echo Maven and npm package scanning ([#&#8203;10883](https://github.com/aquasecurity/trivy/issues/10883)) ([7c1b1fa](https://github.com/aquasecurity/trivy/commit/7c1b1fa19f1628132a9e8377fed127682500d87d))
- **vuln:** extend RapidFort scanner to Debian, Oracle, Rocky, Alma, and Amazon ([#&#8203;11285](https://github.com/aquasecurity/trivy/issues/11285)) ([aaebec6](https://github.com/aquasecurity/trivy/commit/aaebec6cf772111b2bd1dca221e0c36e0a952817))

##### Bug Fixes

- **echo:** match +echo.N local segment anywhere in pip versions ([#&#8203;11367](https://github.com/aquasecurity/trivy/issues/11367)) ([bfb43a4](https://github.com/aquasecurity/trivy/commit/bfb43a49642fbdf60f5e794bba5982fdaa433136))
- **php:** keep dependency edges to packages named like PHP extensions ([#&#8203;11051](https://github.com/aquasecurity/trivy/issues/11051)) ([0900c7e](https://github.com/aquasecurity/trivy/commit/0900c7eb5a29f1169a3fdabd6ce4b45da2271400))
- **vex:** avoid panic on CSAF advisory without a CVE ([#&#8203;10990](https://github.com/aquasecurity/trivy/issues/10990)) ([431288f](https://github.com/aquasecurity/trivy/commit/431288f897ff543f19c49274dcc1df1a3bef8664))

### [`v0.75.0`](https://github.com/aquasecurity/trivy/blob/HEAD/CHANGELOG.md#0750-2026-10-01)

[Compare Source](https://github.com/aquasecurity/trivy/compare/v0.74.0...v0.75.0)

##### ⚠ BREAKING CHANGES

- **report:** remove getHostByName from templates ([#&#8203;11206](https://github.com/aquasecurity/trivy/issues/11206))

##### Features

- add cryptographic asset model and parser ([#&#8203;10970](https://github.com/aquasecurity/trivy/issues/10970)) ([64e1715](https://github.com/aquasecurity/trivy/commit/64e17158b838f3154be3c75cd4799d058143ea92))
- **cli:** allow disabling configuration files with empty paths ([#&#8203;11210](https://github.com/aquasecurity/trivy/issues/11210)) ([5f00edd](https://github.com/aquasecurity/trivy/commit/5f00edd05931cb8034242668e3951aa9aa723db1))
- **crypto:** add analyzer and pass assets to the scan report ([#&#8203;11104](https://github.com/aquasecurity/trivy/issues/11104)) ([fb7ad28](https://github.com/aquasecurity/trivy/commit/fb7ad289bdf017e697d7633942774d2c91f7f298))
- **crypto:** add the crypto scanner to the image command ([#&#8203;11144](https://github.com/aquasecurity/trivy/issues/11144)) ([dc9a384](https://github.com/aquasecurity/trivy/commit/dc9a38453595894876b4c2290d3c61279da44c5d))
- **crypto:** describe ML-DSA keys and signature algorithms ([#&#8203;11137](https://github.com/aquasecurity/trivy/issues/11137)) ([20c3c35](https://github.com/aquasecurity/trivy/commit/20c3c3520b01a0083e6155e5e547f803d41ddfd8))
- **crypto:** describe parsed material as cryptographic assets ([#&#8203;11092](https://github.com/aquasecurity/trivy/issues/11092)) ([7d0a892](https://github.com/aquasecurity/trivy/commit/7d0a892930369a387c31c68f4390131be0741022))
- **crypto:** output cryptographic assets in CycloneDX ([#&#8203;11125](https://github.com/aquasecurity/trivy/issues/11125)) ([3897d5c](https://github.com/aquasecurity/trivy/commit/3897d5c35e2dfa4d8d0ed15bf958fe5e943a91b4))
- **crypto:** transfer cryptographic assets in client/server mode ([#&#8203;11141](https://github.com/aquasecurity/trivy/issues/11141)) ([4128b7f](https://github.com/aquasecurity/trivy/commit/4128b7f4ece535c1c0ca60ee5766f5016efd65e0))
- **echo:** add vulnerability detection for Echo-patched Python packages ([#&#8203;10555](https://github.com/aquasecurity/trivy/issues/10555)) ([98787b8](https://github.com/aquasecurity/trivy/commit/98787b870c109531416cea6019a9b55af224a101))

##### Bug Fixes

- avoid panics on malformed dependency files and version-less Amazon Linux release ([#&#8203;10996](https://github.com/aquasecurity/trivy/issues/10996)) ([ef28d95](https://github.com/aquasecurity/trivy/commit/ef28d95fea53a7456ec631635ef8556861faee8a))
- correct grammar and typos in user-facing error messages ([#&#8203;11211](https://github.com/aquasecurity/trivy/issues/11211)) ([a8c8409](https://github.com/aquasecurity/trivy/commit/a8c8409ef130b617524f71a12f6faa4cb44a04ab))
- correct grammar and typos in user-facing error messages and CLI flags ([#&#8203;11281](https://github.com/aquasecurity/trivy/issues/11281)) ([5ba5be0](https://github.com/aquasecurity/trivy/commit/5ba5be055fb0ad060403100c54b2aecae62c7e9e))
- **crypto:** read RSA private keys without validating their math ([#&#8203;11319](https://github.com/aquasecurity/trivy/issues/11319)) ([3683d7d](https://github.com/aquasecurity/trivy/commit/3683d7d497b60084057f8b332176a32b75cb473a))
- **go:** honor go directive when merging go.sum ([#&#8203;11169](https://github.com/aquasecurity/trivy/issues/11169)) ([71190a6](https://github.com/aquasecurity/trivy/commit/71190a68a9108aefa7131ad4249fa077e3d09816))
- **go:** restore stdlib version parsing for vendor-patched Go toolchains ([#&#8203;11119](https://github.com/aquasecurity/trivy/issues/11119)) ([a851889](https://github.com/aquasecurity/trivy/commit/a851889c930eb8a604dec96ad9a783d75e2b6ac6))
- **license:** report unparsable license names with UNKNOWN severity ([#&#8203;11254](https://github.com/aquasecurity/trivy/issues/11254)) ([7b598ab](https://github.com/aquasecurity/trivy/commit/7b598ab7a97bd01c4ad1ab1f80c23a2574915410))
- **license:** use canonical SPDX casing for license.id ([#&#8203;11165](https://github.com/aquasecurity/trivy/issues/11165)) ([89d3acf](https://github.com/aquasecurity/trivy/commit/89d3acfce93a34e2120dbff0f71c947aadce4c83))
- **misconf:** report correct line numbers in multi-document manifests ([#&#8203;11207](https://github.com/aquasecurity/trivy/issues/11207)) ([4eac9a0](https://github.com/aquasecurity/trivy/commit/4eac9a04f2c2b3ae990b9b361d14b65103278c7b))
- **nodejs:** support boolean resolved field in package-lock.json ([#&#8203;11156](https://github.com/aquasecurity/trivy/issues/11156)) ([a2474b8](https://github.com/aquasecurity/trivy/commit/a2474b8410166610633adc7a5a20be1618c63c19))
- **os:** keep the fullest OS version when merging analyzer results ([#&#8203;11039](https://github.com/aquasecurity/trivy/issues/11039)) ([0afeae0](https://github.com/aquasecurity/trivy/commit/0afeae01abcf4a4d6a1538a716a81dae7e2c203f))
- **purl:** classify julia, bottlerocket and centos stream packages ([#&#8203;11326](https://github.com/aquasecurity/trivy/issues/11326)) ([3a1b311](https://github.com/aquasecurity/trivy/commit/3a1b311e63a1b64ab3221bf52683581b77187198))
- **python:** skip pip requirement lines with malformed extras brackets ([#&#8203;11300](https://github.com/aquasecurity/trivy/issues/11300)) ([7e71d21](https://github.com/aquasecurity/trivy/commit/7e71d211f51f2599af7ded5fbfad96b50430446e))
- **python:** support uv workspace lockfiles ([#&#8203;10553](https://github.com/aquasecurity/trivy/issues/10553)) ([a072319](https://github.com/aquasecurity/trivy/commit/a072319acd27e4ef85d73ff7b4c980b5e0646671))
- **report:** remove getHostByName from templates ([#&#8203;11206](https://github.com/aquasecurity/trivy/issues/11206)) ([9b2b830](https://github.com/aquasecurity/trivy/commit/9b2b830877a78ab77999a9fe2c4526b8cd4b922a))
- **repo:** strip credentials from remote repository URL in artifact name ([#&#8203;11213](https://github.com/aquasecurity/trivy/issues/11213)) ([c961eeb](https://github.com/aquasecurity/trivy/commit/c961eebeab1fa21330792abfc818236867e6e5ac))
- **sbom:** skip null entries in SPDX file and package arrays ([#&#8203;11101](https://github.com/aquasecurity/trivy/issues/11101)) ([0aaaa71](https://github.com/aquasecurity/trivy/commit/0aaaa7174d978e04d75d39a9494ff5b0245cdc53))
- **server:** propagate package modularity label, build info and installed files ([#&#8203;11188](https://github.com/aquasecurity/trivy/issues/11188)) ([bf9f5b7](https://github.com/aquasecurity/trivy/commit/bf9f5b781ec7128e145367c8b5f9890117471fff))
- set locations for JSON values sharing a line ([#&#8203;11231](https://github.com/aquasecurity/trivy/issues/11231)) ([e5b5a3a](https://github.com/aquasecurity/trivy/commit/e5b5a3ac5876550eff50b1e14949589d91e01976))
- **terraform:** do not override --skip-files with --skip-dirs ([#&#8203;11191](https://github.com/aquasecurity/trivy/issues/11191)) ([1c8c54f](https://github.com/aquasecurity/trivy/commit/1c8c54fe9e2d18411cd997d5009a7771730f1481))
- **vex:** avoid panic on CSAF relationships without a sub-component ([#&#8203;11067](https://github.com/aquasecurity/trivy/issues/11067)) ([ae561f8](https://github.com/aquasecurity/trivy/commit/ae561f8cca36b4b11434b0a6d171b39ec1ad871e))

##### Performance Improvements

- avoid regrowing the buffer when reading a cached file ([#&#8203;11134](https://github.com/aquasecurity/trivy/issues/11134)) ([25521f4](https://github.com/aquasecurity/trivy/commit/25521f48ea415d3886d5f5cdc820937b25fb302d))
- **crypto:** report repeated x509 material once per file ([#&#8203;11263](https://github.com/aquasecurity/trivy/issues/11263)) ([f6423f6](https://github.com/aquasecurity/trivy/commit/f6423f6053ddbba178f99e1e8878ba1a46bb5d80))
- reuse one JSON unmarshaler per document ([#&#8203;11232](https://github.com/aquasecurity/trivy/issues/11232)) ([e97dfcc](https://github.com/aquasecurity/trivy/commit/e97dfcc1bd777cdc85a2aedb52b761ea543b9ae0))
- **secret:** avoid cloning the logger for every rule ([#&#8203;11133](https://github.com/aquasecurity/trivy/issues/11133)) ([ab3cf86](https://github.com/aquasecurity/trivy/commit/ab3cf8625cf461e5471259e50681d230017b2b65))
- **secret:** replace per-rule keyword search with one Aho-Corasick pass ([#&#8203;11179](https://github.com/aquasecurity/trivy/issues/11179)) ([f372e56](https://github.com/aquasecurity/trivy/commit/f372e564e5ad6d02bf820a90b477913f827e5a1e))
- take JSON line numbers from decoder offsets ([#&#8203;11233](https://github.com/aquasecurity/trivy/issues/11233)) ([7e21433](https://github.com/aquasecurity/trivy/commit/7e21433cb3cdb61118cc7d1704446541f35e8396))

</details>

---

### Configuration

📅 **Schedule**: (in timezone Europe/Paris)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yNTcuOSIsInVwZGF0ZWRJblZlciI6IjQ0LjI1Ny45IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJib3QiLCJtaW5vciJdfQ==-->

Reviewed-on: https://git.djeex.fr/Djeex/nvidia-stock-bot/pulls/38
Co-authored-by: Djeex <[email protected]>
2026-11-21 19:44:48 +01:00
Djeex 67f94fd2c0 Track CI tool images with Renovate (#37)
CI / build-and-scan (push) Successful in 28s
## Summary
- Custom Renovate manager for the CI tool images pinned in `docker run`/`docker create` commands (Trivy, gitleaks, hadolint), which the default managers do not detect.
- Renovate will now open PRs to bump them; they are not automerged.

## Test plan
- [ ] CI green on this PR
- [ ] After merge, Renovate opens a PR bumping Trivy
- [ ] That PR passes CI before merging

Reviewed-on: #37
Co-authored-by: Djeex <[email protected]>
2026-11-21 18:46:58 +01:00
Djeex 9189c4f639 Pin image digests and add minimum release age (#36)
CI / build-and-scan (push) Successful in 28s
## Summary
- `docker:pinDigests`: Renovate pins image digests and opens digest PRs when a base image is rebuilt, so security fixes are picked up.
- `minimumReleaseAge`: 3 days globally, 7 days for pip.
- Automerge for `pin` and `digest` updates, like patch updates.

## Test plan
- [x] CI green on this PR
- [x] After merge, Renovate opens a pin PR for the Dockerfile digests
- [x] That PR automerges once CI passes

Reviewed-on: #36
Co-authored-by: Djeex <[email protected]>
2026-11-21 18:13:42 +01:00
nvidia-stock-bot-ci 159182e6a1 Bump build version to 4.1.4 [skip ci] 2026-10-30 04:17:26 +00:00
Djeex d0f76b9978 chore(deps): update python docker tag to v3.15.2
CI / build-and-scan (pull_request) Successful in 24s
CI / build-and-scan (push) Successful in 37s
2026-10-30 04:05:21 +00:00
nvidia-stock-bot-ci b61feb4fef Bump build version to 4.1.3 [skip ci] 2026-10-24 12:54:39 +00:00
Djeex 2825c2dbfd chore(deps): update python docker tag to v3.15.1 (#34)
CI / build-and-scan (push) Successful in 36s
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| python | final | minor | `3.14.8-alpine` -> `3.15.1-alpine` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yNjQuMCIsInVwZGF0ZWRJblZlciI6IjM5LjI2NC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJib3QiLCJtaW5vciJdfQ==-->

Reviewed-on: #34
2026-10-24 14:52:24 +02:00
nvidia-stock-bot-ci 3ef6fc9409 Bump build version to 4.1.2 [skip ci] 2026-10-02 03:10:12 +00:00
Djeex ec2682d675 chore(deps): update python docker tag to v3.14.8
CI / build-and-scan (pull_request) Successful in 53s
CI / build-and-scan (push) Successful in 39s
2026-10-02 03:01:01 +00:00
nvidia-stock-bot-ci d90b7cdbf8 Bump build version to 4.1.1 [skip ci] 2026-08-26 13:45:26 +00:00
Djeex 5a7a60d299 CI/CD hardening: lint, secret scan, coverage gate, auto CVE-fix PRs, GHCR + GitHub mirror publishing (#32)
CI / build-and-scan (push) Successful in 1m37s
- release changelog: commits rendered as description (link), divider lines dropped
- gitleaks secret scan and hadolint on every push/PR
- ruff lint/format gate (Python repos) with a pytest --cov-fail-under gate
- scheduled CRITICAL Trivy failures attempt an apk upgrade rebuild and open a follow-up PR if it clears the finding, instead of just failing red
- images also published to ghcr.io/djeex/<repo>
- a matching GitHub Release is created on the GitHub mirror, with a notice pointing back to this repo as the source of truth
2026-08-26 15:43:40 +02:00
Djeex b3ed21eec2 Merge pull request 'Align CI release workflow with adguard-cidre/socat-proxy template' (#31) from fix-ci-release-template into main
CI / build-and-scan (push) Successful in 31s
Reviewed-on: #31
2026-08-23 23:24:58 +02:00
Djeex b0a220e7a2 Link each commit in the release changelog to its own commit page
CI / build-and-scan (pull_request) Successful in 56s
COMMIT_LIST only rendered the bare subject line per commit, with no
way to jump to that specific commit — only the triggering commit
(Source:) had a link. Each line now reads
"- [<short-sha>](<repo>/commit/<sha>) <subject>", matching the same
link style already used for Source.
2026-08-23 23:20:51 +02:00
Djeex ae737c0bd0 Align CI release workflow with adguard-cidre/socat-proxy template
CI / build-and-scan (pull_request) Successful in 1m59s
The publish/release step had drifted from the sibling repos' reference
template: PR-number extraction relied on the local commit log after
the version-bump commit was already made, so it could never find the
triggering PR (that commit's own message has no PR reference) — fixed
by keying off github.sha, the fixed triggering commit, instead.

Also aligned: docker login casing (Djeex, not djeex), Trivy pinned to
0.74.0, deprecation check made informative instead of build-blocking,
publish skipped entirely when no container-relevant file changed, and
the release body now lists the individual commits (with a --- divider
under each heading) instead of the raw changed-files list.
2026-08-23 22:39:58 +02:00
Djeex d0b3fc6e18 Merge pull request 'Run as non-root (911:911), bump to 4.1.0' (#30) from dev-v4.1 into main
CI / build-and-scan (push) Successful in 36s
Reviewed-on: #30
2026-08-23 15:17:09 +02:00
Djeex 5f66d1e1e0 Run as non-root (911:911), bump to 4.1.0
CI / build-and-scan (pull_request) Successful in 58s
2026-08-23 14:35:41 +02:00
gitea-ci-bot 8b7eac51c8 chore: bump version to 4.0.5 [skip ci] 2026-08-22 21:18:17 +00:00
Djeex fb1387e6cc Merge pull request 'chore(deps): update python docker tag to v3.14.7' (#28) from renovate/python-3.x into main
Reviewed-on: #28
2026-08-22 23:17:44 +02:00
Djeex d972fdf145 chore(deps): update python docker tag to v3.14.7 2026-08-22 21:16:28 +00:00
gitea-ci-bot 753750530d chore: bump version to 4.0.4 [skip ci] 2026-08-22 21:14:15 +00:00
Djeex f4f41abbe8 Merge pull request 'Add Gitea Actions CI/CD pipeline' (#27) from dev-ci into main
Reviewed-on: #27
2026-08-22 23:13:45 +02:00
Djeex 7fb3663097 Cover notifier.py error paths (TEST_MODE, HTTP error, connection error)
Brings app/notifier.py from 73% to 100% test coverage by exercising the
three notification functions' TEST_MODE early-return, non-204 response,
and requests exception branches — the exact paths a requests upgrade
regression would break silently.
2026-08-22 23:08:33 +02:00
Djeex 530aeba667 Add Gitea Actions CI/CD pipeline
Bring nvidia-stock-bot up to the same CI/CD maturity as adguard-cidre:
pytest suite (19 tests), multi-stage Dockerfile with a dedicated test
stage, pinned requests dependency, Gitea Actions workflow (build, smoke
test, unit tests, deprecation check, Trivy critical/high scan, version
bump + registry publish + release), and a Renovate config for automated
dependency updates.
2026-08-22 22:54:18 +02:00
16 changed files with 763 additions and 73 deletions

No files matched your search

+118
View File
@@ -0,0 +1,118 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
# Saturday 05:00 UTC: 06:00 in Paris in winter, 07:00 in summer (Gitea runs cron in UTC).
- cron: "0 5 * * 6"
jobs:
build-and-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Get shared actions
uses: actions/checkout@v7
with:
repository: labeex/cicdeex
ref: 1.1.0
token: ${{ secrets.CICDEEX_TOKEN }}
path: .cicdeex
persist-credentials: false
- name: Scan for secrets
uses: ./.cicdeex/secret-scan
- name: Lint Dockerfile with hadolint
uses: ./.cicdeex/hadolint
- name: Build Docker image
run: |
docker build -t nvidia-stock-bot:ci . 2>&1 | tee build.log
if grep -q "Building wheel for" build.log; then
echo "::warning::A dependency was built from source — check Python/Alpine compatibility"
fi
- name: Smoke test (syntax check)
run: |
docker run --rm --entrypoint python nvidia-stock-bot:ci -c "
import ast, glob
ok = True
for f in glob.glob('/app/*.py'):
with open(f) as fh:
source = fh.read()
try:
ast.parse(source, filename=f)
except SyntaxError as e:
print(f'::error::Syntax error in {f}: {e}')
ok = False
if not ok:
exit(1)
print('OK: syntax is valid')
"
- name: Run unit tests
run: |
docker build --target test -t nvidia-stock-bot:test .
docker run --rm nvidia-stock-bot:test pytest -v --cov=. --cov-report=term-missing --cov-fail-under=75
- name: Lint with ruff
run: docker build --target lint -t nvidia-stock-bot:lint .
- name: Check deprecation warnings
run: |
docker run --rm --entrypoint python \
-e DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/123456789012345678/abcdef" \
-e PRODUCT_NAMES="RTX 5090 Founders Edition" \
-e TEST_MODE=True \
nvidia-stock-bot:ci -W error::DeprecationWarning -c "import main" 2>&1 | tee deprecation.log || true
if grep -qi "deprecat" deprecation.log; then
echo "::warning::Deprecation warning detected, check logs"
fi
- name: Scan with Trivy (critical - blocking)
id: trivy_critical
continue-on-error: true
uses: ./.cicdeex/trivy
with:
image: nvidia-stock-bot:ci
- name: Handle CRITICAL findings
if: steps.trivy_critical.outcome == 'failure'
uses: ./.cicdeex/remediate
with:
push-token: ${{ secrets.CI_PUSH_TOKEN }}
- name: Scan with Trivy (high - informative)
uses: ./.cicdeex/trivy
with:
image: nvidia-stock-bot:ci
severity: HIGH
exit-code: "0"
- name: Publish tagged image
id: publish
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: ./.cicdeex/publish
with:
image: nvidia-stock-bot:ci
paths: '^(Dockerfile|VERSION)$|^app/'
push-token: ${{ secrets.CI_PUSH_TOKEN }}
registry-token: ${{ secrets.REGISTRY_TOKEN }}
github-mirror: "true"
github-token: ${{ secrets.GH_TOKEN }}
- name: Notify failures
if: always()
uses: ./.cicdeex/notify
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
status: ${{ job.status }}
+3 -1
View File
@@ -1,2 +1,4 @@
.venv
__pycache__/
__pycache__/
.coverage
.pytest_cache/
+24 -2
View File
@@ -1,4 +1,4 @@
FROM python:3.13-alpine
FROM python:3.15.2-alpine@sha256:0f9552bb28711333da16915ec146f5e6bb44a7fdac9ced15dc17c2e0206346dd AS base
RUN apk add --no-cache ca-certificates
@@ -9,4 +9,26 @@ COPY /app/ /app/
RUN pip install --no-cache-dir -r requirements.txt
CMD ["python", "main.py"]
FROM base AS test
RUN pip install --no-cache-dir pytest==9.1.1 pytest-cov==7.1.0
COPY pytest.ini /app/pytest.ini
COPY /tests/ /app/tests/
CMD ["pytest", "-v"]
FROM base AS lint
RUN pip install --no-cache-dir ruff==0.16.4
COPY ruff.toml /app/ruff.toml
COPY /tests/ /app/tests/
RUN ruff check . && ruff format --check .
FROM base
RUN addgroup -g 911 nvbot && adduser -D -u 911 -G nvbot nvbot
USER nvbot
CMD ["python", "main.py"]
+1 -1
View File
@@ -1 +1 @@
4.0.3
4.1.5
+42 -31
View File
@@ -1,11 +1,13 @@
import json
import logging
import os
import re
import logging
import json
import sys
# Read version from VERSION file
with open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "VERSION"), "r", encoding="utf-8") as f:
with open(
os.path.join(os.path.dirname(os.path.dirname(__file__)), "VERSION"), encoding="utf-8"
) as f:
VERSION = f.read().strip()
# Logger setup
@@ -23,13 +25,13 @@ logging.info("=" * 60)
# Env variables
try:
DISCORD_WEBHOOK_URL = os.environ['DISCORD_WEBHOOK_URL']
DISCORD_SERVER_NAME = os.environ.get('DISCORD_SERVER_NAME', 'Shared for free')
DISCORD_ROLES = os.environ.get('DISCORD_ROLES')
COUNTRY = os.environ.get('COUNTRY') or 'US'
REFRESH_TIME = int(os.environ.get('REFRESH_TIME') or 30)
TEST_MODE = os.environ.get('TEST_MODE', 'False').lower() == 'true'
PRODUCT_NAMES = os.environ['PRODUCT_NAMES']
DISCORD_WEBHOOK_URL = os.environ["DISCORD_WEBHOOK_URL"]
DISCORD_SERVER_NAME = os.environ.get("DISCORD_SERVER_NAME", "Shared for free")
DISCORD_ROLES = os.environ.get("DISCORD_ROLES")
COUNTRY = os.environ.get("COUNTRY") or "US"
REFRESH_TIME = int(os.environ.get("REFRESH_TIME") or 30)
TEST_MODE = os.environ.get("TEST_MODE", "False").lower() == "true"
PRODUCT_NAMES = os.environ["PRODUCT_NAMES"]
# Errors and warning
except KeyError as e:
@@ -49,32 +51,32 @@ if not DISCORD_WEBHOOK_URL:
logging.error("❌ DISCORD_WEBHOOK_URL is required but not defined.")
sys.exit(1)
PRODUCT_NAMES = [name.strip() for name in PRODUCT_NAMES.split(',')]
PRODUCT_NAMES = [name.strip() for name in PRODUCT_NAMES.split(",")]
# Role mapping
DISCORD_ROLE_MAP = {}
if not DISCORD_ROLES or not DISCORD_ROLES.strip():
logging.warning("⚠️ DISCORD_ROLES not defined or empty. Defaulting all roles to @everyone.")
for name in PRODUCT_NAMES:
DISCORD_ROLE_MAP[name] = '@everyone'
DISCORD_ROLE_MAP[name] = "@everyone"
else:
roles = [r.strip() if r.strip() else '@everyone' for r in DISCORD_ROLES.split(',')]
roles = [r.strip() if r.strip() else "@everyone" for r in DISCORD_ROLES.split(",")]
if len(roles) != len(PRODUCT_NAMES):
logging.error("❌ The number of DISCORD_ROLES must match PRODUCT_NAMES.")
sys.exit(1)
for name, role in zip(PRODUCT_NAMES, roles):
if role != '@everyone' and not re.match(r'^<@&\d{17,20}>$', role):
if role != "@everyone" and not re.match(r"^<@&\d{17,20}>$", role):
logging.error(f"❌ Invalid DISCORD_ROLE format for {name}: {role}")
sys.exit(1)
DISCORD_ROLE_MAP[name] = role
# Masked webhook in terminal
match = re.search(r'/(\d+)/(.*)', DISCORD_WEBHOOK_URL)
match = re.search(r"/(\d+)/(.*)", DISCORD_WEBHOOK_URL)
if match:
webhook_id = match.group(1)
webhook_token = match.group(2)
masked_webhook_id = webhook_id[:len(webhook_id) - 10] + '*' * 10
masked_webhook_token = webhook_token[:len(webhook_token) - 120] + '*' * 10
masked_webhook_id = webhook_id[: len(webhook_id) - 10] + "*" * 10
masked_webhook_token = webhook_token[: len(webhook_token) - 120] + "*" * 10
wh_masked_url = f"https://discord.com/api/webhooks/{masked_webhook_id}/{masked_webhook_token}"
else:
wh_masked_url = "[Invalid webhook URL]"
@@ -90,29 +92,33 @@ HEADERS = {
"Connection": "keep-alive",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Ch-Ua": "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not.A/Brand\";v=\"24\"",
"Sec-Ch-Ua-Platform": "\"macOS\"",
"Sec-Ch-Ua": '"Google Chrome";v="131", "Chromium";v="131", "Not.A/Brand";v="24"',
"Sec-Ch-Ua-Platform": '"macOS"',
"Cache-Control": "no-cache, no-store, must-revalidate",
"Pragma": "no-cache",
"Expires": "0"
"Expires": "0",
}
# Load country setting and localization config
country_code = os.environ.get("COUNTRY", "US").upper()
try:
with open("localization.json", "r", encoding="utf-8") as f:
with open("localization.json", encoding="utf-8") as f:
localization_config = json.load(f)
except FileNotFoundError:
logging.error("❌ localization.json file not found.")
sys.exit(1)
# Find country entry
country_entry = next((entry for entry in localization_config if entry["country_code"].upper() == country_code), None)
country_entry = next(
(entry for entry in localization_config if entry["country_code"].upper() == country_code), None
)
if not country_entry:
logging.warning(f"⚠️ Country '{country_code}' not found in localization.json. Defaulting to US.")
country_entry = next((entry for entry in localization_config if entry["country_code"].upper() == "US"), None)
country_entry = next(
(entry for entry in localization_config if entry["country_code"].upper() == "US"), None
)
if not country_entry:
logging.error("❌ US fallback not found in localization.json.")
sys.exit(1)
@@ -124,7 +130,7 @@ currency = country_entry["currency"]
# Load language file
try:
with open("languages.json", "r", encoding="utf-8") as f:
with open("languages.json", encoding="utf-8") as f:
loc_lang = json.load(f)
except FileNotFoundError:
logging.error("❌ languages.json file not found.")
@@ -141,9 +147,15 @@ if not loc:
# Ensure all required keys are present
required_keys = [
"in_stock_title", "out_of_stock_title", "sku_change_title",
"buy_now", "price", "time", "footer",
"sku_description", "imminent_drop"
"in_stock_title",
"out_of_stock_title",
"sku_change_title",
"buy_now",
"price",
"time",
"footer",
"sku_description",
"imminent_drop",
]
missing_keys = [key for key in required_keys if key not in loc]
fallback = loc_lang.get("en", {})
@@ -159,17 +171,16 @@ for key in missing_keys:
locale = full_lang_code.lower()
API_URL_SKU = os.getenv(
"API_URL_SKU",
f"https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale={locale}&Manufacturer=Nvidia"
f"https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale={locale}&Manufacturer=Nvidia",
)
API_URL_STOCK = os.getenv(
"API_URL_STOCK",
f"https://api.store.nvidia.com/partner/v1/feinventory?locale={locale}&skus="
"API_URL_STOCK", f"https://api.store.nvidia.com/partner/v1/feinventory?locale={locale}&skus="
)
PRODUCT_URL = os.getenv(
"PRODUCT_URL",
f"https://marketplace.nvidia.com/{locale}/consumer/graphics-cards/?locale={locale}&page=1&limit=12&manufacturer=NVIDIA"
f"https://marketplace.nvidia.com/{locale}/consumer/graphics-cards/?locale={locale}&page=1&limit=12&manufacturer=NVIDIA",
)
# Public constants
+21 -14
View File
@@ -1,21 +1,28 @@
import requests
import logging
import time
from env_config import HEADERS, PRODUCT_NAMES, API_URL_SKU, API_URL_STOCK, PRODUCT_URL
from notifier import send_discord_notification, send_out_of_stock_notification, send_sku_change_notification
import requests
from requests.adapters import HTTPAdapter, Retry
from env_config import API_URL_SKU, API_URL_STOCK, HEADERS, PRODUCT_NAMES, PRODUCT_URL
from notifier import (
send_discord_notification,
send_out_of_stock_notification,
send_sku_change_notification,
)
# HTTP session
session = requests.Session()
retries = Retry(total=5, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
session.mount('https://', HTTPAdapter(max_retries=retries))
session.mount("https://", HTTPAdapter(max_retries=retries))
session.headers.update(HEADERS)
# Keeping memory of last run
# Keeping memory of last run
last_sku_dict = {}
global_stock_status_dict = {}
first_run_dict = {name: True for name in PRODUCT_NAMES}
# Stock check function
def check_rtx_50_founders():
global last_sku_dict, global_stock_status_dict, first_run_dict
@@ -24,7 +31,7 @@ def check_rtx_50_founders():
try:
cache_buster = int(time.time() * 1000)
sku_url = f"{API_URL_SKU}&_t={cache_buster}"
response = session.get(sku_url, timeout=10)
logging.info(f"SKU API response: {response.status_code}")
response.raise_for_status()
@@ -32,9 +39,9 @@ def check_rtx_50_founders():
except requests.exceptions.RequestException as e:
logging.error(f"SKU API error: {e}")
return
# Checking productSKU and productUPC for all GPU set in PRODUCT_NAME
all_products = data['searchedProducts']['productDetails']
all_products = data["searchedProducts"]["productDetails"]
for product_name in PRODUCT_NAMES:
product_details = None
@@ -47,8 +54,8 @@ def check_rtx_50_founders():
logging.warning(f"⚠️ No product with GPU '{product_name}' found.")
continue
product_sku = product_details['productSKU']
product_upc = product_details.get('productUPC', "")
product_sku = product_details["productSKU"]
product_upc = product_details.get("productUPC", "")
if not isinstance(product_upc, list):
product_upc = [product_upc]
@@ -60,7 +67,7 @@ def check_rtx_50_founders():
last_sku_dict[product_name] = product_sku
first_run_dict[product_name] = False
# Check product availability in API_URL_STOCK for each SKU
cache_buster = int(time.time() * 1000)
api_stock_url = f"{API_URL_STOCK}{product_sku}&_t={cache_buster}"
@@ -80,8 +87,8 @@ def check_rtx_50_founders():
products_price = "Price not available"
if isinstance(products, list) and len(products) > 0:
for p in products:
price = p.get("price", 'Price not available')
if price != 'Price not available':
price = p.get("price", "Price not available")
if price != "Price not available":
products_price = price
break
else:
@@ -93,7 +100,7 @@ def check_rtx_50_founders():
is_active = p.get("is_active") == "true"
if is_active and any(upc.upper() in gpu_name for upc in product_upc):
found_in_stock.add(gpu_name)
# Comparing previous state and notify
for upc in product_upc:
upc_upper = upc.upper()
+6 -4
View File
@@ -1,17 +1,20 @@
import time
import logging
import signal
import sys
from gpu_checker import check_rtx_50_founders
import time
from env_config import REFRESH_TIME
from gpu_checker import check_rtx_50_founders
# Signal handler function
def handle_exit(signum, frame):
logging.info(f"🛑 Received signal {signum}. Exiting gracefully...")
sys.exit(0)
# Register signal handlers
signal.signal(signal.SIGINT, handle_exit) # Ctrl+C
signal.signal(signal.SIGINT, handle_exit) # Ctrl+C
signal.signal(signal.SIGTERM, handle_exit) # docker stop / kill -15
if __name__ == "__main__":
@@ -24,4 +27,3 @@ if __name__ == "__main__":
except KeyboardInterrupt:
logging.info("🛑 Script interrupted by user (KeyboardInterrupt). Exiting gracefully.")
sys.exit(0)
+43 -19
View File
@@ -1,15 +1,29 @@
import time
import logging
import time
import requests
from env_config import (
DISCORD_WEBHOOK_URL, DISCORD_SERVER_NAME, DISCORD_ROLE_MAP, TEST_MODE, currency,
in_stock_title, out_of_stock_title, sku_change_title,
buy_now, price_label, time_label, footer, sku_description, imminent_drop
DISCORD_ROLE_MAP,
DISCORD_SERVER_NAME,
DISCORD_WEBHOOK_URL,
TEST_MODE,
buy_now,
currency,
footer,
imminent_drop,
in_stock_title,
out_of_stock_title,
price_label,
sku_change_title,
sku_description,
time_label,
)
AVATAR = "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/ds_wh_pp.jpg"
THUMBNAIL = "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000.jpg"
# In stock
def send_discord_notification(gpu_name, product_link, products_price):
timestamp = int(time.time())
@@ -24,17 +38,20 @@ def send_discord_notification(gpu_name, product_link, products_price):
"author": {"name": "Nvidia Founder Editions"},
"fields": [
{"name": price_label, "value": f"`{currency}{products_price}`", "inline": True},
{"name": time_label, "value": f"<t:{timestamp}:d> <t:{timestamp}:T>", "inline": True}
{"name": time_label, "value": f"<t:{timestamp}:d> <t:{timestamp}:T>", "inline": True},
],
"description": buy_now.format(product_link=product_link),
"footer": {"text": footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME), "icon_url": AVATAR}
"footer": {
"text": footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME),
"icon_url": AVATAR,
},
}
payload = {
"content": DISCORD_ROLE_MAP.get(gpu_name, "@everyone"),
"username": "NviBot",
"avatar_url": AVATAR,
"embeds": [embed]
"embeds": [embed],
}
try:
@@ -46,6 +63,7 @@ def send_discord_notification(gpu_name, product_link, products_price):
except Exception as e:
logging.error(f"🚨 Error sending webhook: {e}")
# Out of stock
def send_out_of_stock_notification(gpu_name, product_link, products_price):
timestamp = int(time.time())
@@ -59,15 +77,16 @@ def send_out_of_stock_notification(gpu_name, product_link, products_price):
"thumbnail": {"url": THUMBNAIL},
"url": product_link,
"author": {"name": "Nvidia Founder Editions"},
"footer": {"text": footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME), "icon_url": AVATAR},
"fields": [{"name": time_label, "value": f"<t:{timestamp}:d> <t:{timestamp}:T>", "inline": True}]
"footer": {
"text": footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME),
"icon_url": AVATAR,
},
"fields": [
{"name": time_label, "value": f"<t:{timestamp}:d> <t:{timestamp}:T>", "inline": True}
],
}
payload = {
"username": "NviBot",
"avatar_url": AVATAR,
"embeds": [embed]
}
payload = {"username": "NviBot", "avatar_url": AVATAR, "embeds": [embed]}
try:
response = requests.post(DISCORD_WEBHOOK_URL, json=payload)
@@ -78,6 +97,7 @@ def send_out_of_stock_notification(gpu_name, product_link, products_price):
except Exception as e:
logging.error(f"🚨 Error sending webhook: {e}")
# SKU change
def send_sku_change_notification(gpu_name, old_sku, new_sku, product_link):
timestamp = int(time.time())
@@ -90,15 +110,20 @@ def send_sku_change_notification(gpu_name, old_sku, new_sku, product_link):
"url": product_link,
"description": sku_description.format(old_sku=old_sku, new_sku=new_sku),
"color": 16776960,
"footer": {"text": footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME), "icon_url": AVATAR},
"fields": [{"name": time_label, "value": f"<t:{timestamp}:d> <t:{timestamp}:T>", "inline": True}]
"footer": {
"text": footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME),
"icon_url": AVATAR,
},
"fields": [
{"name": time_label, "value": f"<t:{timestamp}:d> <t:{timestamp}:T>", "inline": True}
],
}
payload = {
"content": imminent_drop.format(DISCORD_ROLE=DISCORD_ROLE_MAP.get(gpu_name, '@everyone')),
"content": imminent_drop.format(DISCORD_ROLE=DISCORD_ROLE_MAP.get(gpu_name, "@everyone")),
"username": "NviBot",
"avatar_url": AVATAR,
"embeds": [embed]
"embeds": [embed],
}
try:
@@ -109,4 +134,3 @@ def send_sku_change_notification(gpu_name, old_sku, new_sku, product_link):
logging.error(f"❌ Webhook error: {response.status_code} - {response.text}")
except Exception as e:
logging.error(f"🚨 Error sending webhook: {e}")
+1 -1
View File
@@ -1 +1 @@
requests
requests==2.34.2
+1
View File
@@ -0,0 +1 @@
[pytest]
+4
View File
@@ -0,0 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["local>labeex/renovateex"]
}
+13
View File
@@ -0,0 +1,13 @@
line-length = 100
[lint]
select = ["E", "F", "I", "UP", "B"]
# E501: handled by the formatter. B905: zip() without strict= in env_config.py —
# app-logic change, left for the user to decide (see feedback-no-app-logic-changes).
ignore = ["E501", "B905"]
[lint.isort]
# Pinned explicitly: auto-detection of first-party modules differs between the
# host (app/ subdir + .git present) and the Docker lint stage (flattened to /app,
# no .git) — without this, import-sort results silently diverge between the two.
known-first-party = ["env_config", "gpu_checker", "notifier", "main"]
+17
View File
@@ -0,0 +1,17 @@
import os
import sys
_TESTS_DIR = os.path.dirname(os.path.abspath(__file__))
_REPO_ROOT = os.path.dirname(_TESTS_DIR)
# app/*.py open their JSON config files with plain relative paths, so the
# process cwd must be the directory the app modules live in — matches how
# the Dockerfile runs them (WORKDIR /app).
_APP_DIR = os.path.join(_REPO_ROOT, "app")
if not os.path.isfile(os.path.join(_APP_DIR, "gpu_checker.py")):
_APP_DIR = _REPO_ROOT # container test stage: code copied flat next to tests/
if _APP_DIR not in sys.path:
sys.path.insert(0, _APP_DIR)
os.chdir(_APP_DIR)
+120
View File
@@ -0,0 +1,120 @@
import importlib
import sys
import pytest
MODULE_NAME = "env_config"
VALID_WEBHOOK = "https://discord.com/api/webhooks/123456789012345678/abcdef"
ENV_KEYS = [
"DISCORD_WEBHOOK_URL",
"DISCORD_SERVER_NAME",
"DISCORD_ROLES",
"COUNTRY",
"REFRESH_TIME",
"TEST_MODE",
"PRODUCT_NAMES",
]
def _reload_env_config(monkeypatch, env):
for key in ENV_KEYS:
monkeypatch.delenv(key, raising=False)
for key, value in env.items():
monkeypatch.setenv(key, value)
sys.modules.pop(MODULE_NAME, None)
return importlib.import_module(MODULE_NAME)
def test_missing_webhook_exits(monkeypatch):
with pytest.raises(SystemExit):
_reload_env_config(monkeypatch, {"PRODUCT_NAMES": "RTX 5090"})
def test_missing_product_names_exits(monkeypatch):
with pytest.raises(SystemExit):
_reload_env_config(monkeypatch, {"DISCORD_WEBHOOK_URL": VALID_WEBHOOK})
def test_default_role_map_is_everyone(monkeypatch):
cfg = _reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090, RTX 5080",
},
)
assert cfg.DISCORD_ROLE_MAP == {"RTX 5090": "@everyone", "RTX 5080": "@everyone"}
def test_role_count_mismatch_exits(monkeypatch):
with pytest.raises(SystemExit):
_reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090, RTX 5080",
"DISCORD_ROLES": "<@&123456789012345678>",
},
)
def test_invalid_role_format_exits(monkeypatch):
with pytest.raises(SystemExit):
_reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090",
"DISCORD_ROLES": "not-a-role",
},
)
def test_valid_role_format_accepted(monkeypatch):
cfg = _reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090",
"DISCORD_ROLES": "<@&123456789012345678>",
},
)
assert cfg.DISCORD_ROLE_MAP["RTX 5090"] == "<@&123456789012345678>"
def test_unknown_country_falls_back_to_us(monkeypatch):
cfg = _reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090",
"COUNTRY": "ZZ",
},
)
assert cfg.currency == "$"
def test_known_country_currency(monkeypatch):
cfg = _reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090",
"COUNTRY": "GB",
},
)
assert cfg.currency == "£"
def test_refresh_time_invalid_exits(monkeypatch):
with pytest.raises(SystemExit):
_reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090",
"REFRESH_TIME": "not-a-number",
},
)
+162
View File
@@ -0,0 +1,162 @@
import importlib
import sys
VALID_WEBHOOK = "https://discord.com/api/webhooks/123456789012345678/abcdef"
PRODUCT_NAME = "RTX 5090 Founders Edition"
SKU_PAYLOAD = {
"searchedProducts": {
"productDetails": [{"gpu": PRODUCT_NAME, "productSKU": "SKU-1", "productUPC": "ABC123"}]
}
}
class FakeResponse:
def __init__(self, payload, status_code=200):
self._payload = payload
self.status_code = status_code
def raise_for_status(self):
if self.status_code >= 400:
raise Exception(f"HTTP {self.status_code}")
def json(self):
return self._payload
def _stock_payload(in_stock, price="1999"):
return {
"listMap": [
{"fe_sku": "ABC123", "is_active": "true" if in_stock else "false", "price": price}
]
}
def _import_gpu_checker(monkeypatch):
monkeypatch.setenv("DISCORD_WEBHOOK_URL", VALID_WEBHOOK)
monkeypatch.setenv("PRODUCT_NAMES", PRODUCT_NAME)
monkeypatch.setenv("TEST_MODE", "True")
monkeypatch.delenv("DISCORD_ROLES", raising=False)
for mod in ("env_config", "notifier", "gpu_checker"):
sys.modules.pop(mod, None)
return importlib.import_module("gpu_checker")
def _queue_responses(monkeypatch, checker, *payloads):
responses = [FakeResponse(p) for p in payloads]
monkeypatch.setattr(checker.session, "get", lambda *a, **k: responses.pop(0))
def test_transition_to_in_stock_sends_notification(monkeypatch):
checker = _import_gpu_checker(monkeypatch)
calls = []
monkeypatch.setattr(
checker, "send_discord_notification", lambda *a: calls.append(("in_stock", a))
)
monkeypatch.setattr(
checker, "send_out_of_stock_notification", lambda *a: calls.append(("out_of_stock", a))
)
monkeypatch.setattr(
checker, "send_sku_change_notification", lambda *a: calls.append(("sku_change", a))
)
_queue_responses(monkeypatch, checker, SKU_PAYLOAD, _stock_payload(True))
checker.check_rtx_50_founders()
assert len(calls) == 1
assert calls[0][0] == "in_stock"
assert calls[0][1][0] == PRODUCT_NAME
def test_transition_to_out_of_stock_sends_notification(monkeypatch):
checker = _import_gpu_checker(monkeypatch)
calls = []
monkeypatch.setattr(
checker, "send_discord_notification", lambda *a: calls.append(("in_stock", a))
)
monkeypatch.setattr(
checker, "send_out_of_stock_notification", lambda *a: calls.append(("out_of_stock", a))
)
monkeypatch.setattr(
checker, "send_sku_change_notification", lambda *a: calls.append(("sku_change", a))
)
_queue_responses(monkeypatch, checker, SKU_PAYLOAD, _stock_payload(True))
checker.check_rtx_50_founders()
_queue_responses(monkeypatch, checker, SKU_PAYLOAD, _stock_payload(False))
checker.check_rtx_50_founders()
assert calls[-1][0] == "out_of_stock"
assert calls[-1][1][0] == PRODUCT_NAME
def test_no_duplicate_notification_while_still_in_stock(monkeypatch):
checker = _import_gpu_checker(monkeypatch)
calls = []
monkeypatch.setattr(
checker, "send_discord_notification", lambda *a: calls.append(("in_stock", a))
)
monkeypatch.setattr(
checker, "send_out_of_stock_notification", lambda *a: calls.append(("out_of_stock", a))
)
monkeypatch.setattr(
checker, "send_sku_change_notification", lambda *a: calls.append(("sku_change", a))
)
_queue_responses(monkeypatch, checker, SKU_PAYLOAD, _stock_payload(True))
checker.check_rtx_50_founders()
_queue_responses(monkeypatch, checker, SKU_PAYLOAD, _stock_payload(True))
checker.check_rtx_50_founders()
assert len(calls) == 1
def test_sku_change_triggers_notification_after_first_run(monkeypatch):
checker = _import_gpu_checker(monkeypatch)
sku_change_calls = []
monkeypatch.setattr(checker, "send_discord_notification", lambda *a: None)
monkeypatch.setattr(checker, "send_out_of_stock_notification", lambda *a: None)
monkeypatch.setattr(
checker, "send_sku_change_notification", lambda *a: sku_change_calls.append(a)
)
_queue_responses(monkeypatch, checker, SKU_PAYLOAD, _stock_payload(False))
checker.check_rtx_50_founders()
assert sku_change_calls == [] # first run must never fire a "change" notification
changed_payload = {
"searchedProducts": {
"productDetails": [{"gpu": PRODUCT_NAME, "productSKU": "SKU-2", "productUPC": "ABC123"}]
}
}
_queue_responses(monkeypatch, checker, changed_payload, _stock_payload(False))
checker.check_rtx_50_founders()
assert len(sku_change_calls) == 1
assert sku_change_calls[0][1] == "SKU-1"
assert sku_change_calls[0][2] == "SKU-2"
def test_missing_product_in_api_is_skipped_gracefully(monkeypatch):
checker = _import_gpu_checker(monkeypatch)
calls = []
monkeypatch.setattr(checker, "send_discord_notification", lambda *a: calls.append(a))
empty_payload = {"searchedProducts": {"productDetails": []}}
monkeypatch.setattr(checker.session, "get", lambda *a, **k: FakeResponse(empty_payload))
checker.check_rtx_50_founders() # must not raise, just log a warning and skip
assert calls == []
def test_sku_api_error_is_handled_without_raising(monkeypatch):
checker = _import_gpu_checker(monkeypatch)
def raise_error(*a, **k):
raise checker.requests.exceptions.ConnectionError("boom")
monkeypatch.setattr(checker.session, "get", raise_error)
checker.check_rtx_50_founders() # must not propagate the network error
+187
View File
@@ -0,0 +1,187 @@
import importlib
import sys
VALID_WEBHOOK = "https://discord.com/api/webhooks/123456789012345678/abcdef"
def _import_notifier(monkeypatch, test_mode="False", discord_roles=None):
monkeypatch.setenv("DISCORD_WEBHOOK_URL", VALID_WEBHOOK)
monkeypatch.setenv("PRODUCT_NAMES", "RTX 5090 Founders Edition")
monkeypatch.setenv("TEST_MODE", test_mode)
if discord_roles is not None:
monkeypatch.setenv("DISCORD_ROLES", discord_roles)
else:
monkeypatch.delenv("DISCORD_ROLES", raising=False)
for mod in ("env_config", "notifier"):
sys.modules.pop(mod, None)
return importlib.import_module("notifier")
class FakeResponse:
def __init__(self, status_code=204, text=""):
self.status_code = status_code
self.text = text
def test_test_mode_skips_network_call(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="True")
calls = []
monkeypatch.setattr(notifier.requests, "post", lambda *a, **k: calls.append((a, k)))
notifier.send_discord_notification("RTX 5090 Founders Edition", "https://example.com", "1999")
assert calls == []
def test_in_stock_notification_posts_expected_payload(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
captured = {}
def fake_post(url, json=None, **kwargs):
captured["url"] = url
captured["json"] = json
return FakeResponse()
monkeypatch.setattr(notifier.requests, "post", fake_post)
notifier.send_discord_notification(
"RTX 5090 Founders Edition", "https://example.com/buy", "1999"
)
assert captured["url"] == notifier.DISCORD_WEBHOOK_URL
assert captured["json"]["content"] == "@everyone"
embed = captured["json"]["embeds"][0]
assert "RTX 5090 Founders Edition" in embed["title"]
def test_discord_notification_survives_http_error(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
monkeypatch.setattr(
notifier.requests, "post", lambda *a, **k: FakeResponse(status_code=500, text="boom")
)
notifier.send_discord_notification("RTX 5090 Founders Edition", "https://example.com", "1999")
def test_discord_notification_survives_connection_error(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
def raise_error(*a, **k):
raise notifier.requests.exceptions.ConnectionError("boom")
monkeypatch.setattr(notifier.requests, "post", raise_error)
# Should not raise even though the request itself blew up (network down, DNS, etc.)
notifier.send_discord_notification("RTX 5090 Founders Edition", "https://example.com", "1999")
def test_out_of_stock_test_mode_skips_network_call(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="True")
calls = []
monkeypatch.setattr(notifier.requests, "post", lambda *a, **k: calls.append((a, k)))
notifier.send_out_of_stock_notification(
"RTX 5090 Founders Edition", "https://example.com", "1999"
)
assert calls == []
def test_out_of_stock_notification_posts_on_success(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
captured = {}
def fake_post(url, json=None, **kwargs):
captured["json"] = json
return FakeResponse(status_code=204)
monkeypatch.setattr(notifier.requests, "post", fake_post)
notifier.send_out_of_stock_notification(
"RTX 5090 Founders Edition", "https://example.com/buy", "1999"
)
assert captured["json"]["embeds"][0]["url"] == "https://example.com/buy"
def test_out_of_stock_notification_survives_http_error(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
monkeypatch.setattr(
notifier.requests, "post", lambda *a, **k: FakeResponse(status_code=500, text="boom")
)
# Should not raise even though the webhook call "fails"
notifier.send_out_of_stock_notification(
"RTX 5090 Founders Edition", "https://example.com", "1999"
)
def test_out_of_stock_notification_survives_connection_error(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
def raise_error(*a, **k):
raise notifier.requests.exceptions.ConnectionError("boom")
monkeypatch.setattr(notifier.requests, "post", raise_error)
notifier.send_out_of_stock_notification(
"RTX 5090 Founders Edition", "https://example.com", "1999"
)
def test_sku_change_test_mode_skips_network_call(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="True")
calls = []
monkeypatch.setattr(notifier.requests, "post", lambda *a, **k: calls.append((a, k)))
notifier.send_sku_change_notification(
"RTX 5090 Founders Edition", "old-sku", "new-sku", "https://example.com"
)
assert calls == []
def test_sku_change_notification_survives_http_error(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
monkeypatch.setattr(
notifier.requests, "post", lambda *a, **k: FakeResponse(status_code=500, text="boom")
)
notifier.send_sku_change_notification(
"RTX 5090 Founders Edition", "old-sku", "new-sku", "https://example.com"
)
def test_sku_change_notification_survives_connection_error(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
def raise_error(*a, **k):
raise notifier.requests.exceptions.ConnectionError("boom")
monkeypatch.setattr(notifier.requests, "post", raise_error)
notifier.send_sku_change_notification(
"RTX 5090 Founders Edition", "old-sku", "new-sku", "https://example.com"
)
def test_sku_change_notification_mentions_role_and_skus(monkeypatch):
notifier = _import_notifier(
monkeypatch, test_mode="False", discord_roles="<@&123456789012345678>"
)
captured = {}
def fake_post(url, json=None, **kwargs):
captured["json"] = json
return FakeResponse()
monkeypatch.setattr(notifier.requests, "post", fake_post)
notifier.send_sku_change_notification(
"RTX 5090 Founders Edition", "old-sku-123", "new-sku-456", "https://example.com"
)
assert "<@&123456789012345678>" in captured["json"]["content"]
description = captured["json"]["embeds"][0]["description"]
assert "old-sku-123" in description
assert "new-sku-456" in description