Skip to content

Commit 9d594dd

Browse files
Enhance CI/CD workflows with granular testing and documentation checks
Co-authored-by: nicoragne <nicoragne@hotmail.fr>
1 parent c9fff75 commit 9d594dd

File tree

6 files changed

+275
-4
lines changed

6 files changed

+275
-4
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "^http://localhost"
5+
},
6+
{
7+
"pattern": "^https://localhost"
8+
},
9+
{
10+
"pattern": "^http://127.0.0.1"
11+
},
12+
{
13+
"pattern": "^https://127.0.0.1"
14+
}
15+
],
16+
"httpHeaders": [
17+
{
18+
"urls": ["https://github.com"],
19+
"headers": {
20+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
21+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0"
22+
}
23+
}
24+
],
25+
"timeout": "10s",
26+
"retryOn429": true,
27+
"retryCount": 3,
28+
"fallbackRetryDelay": "30s",
29+
"aliveStatusCodes": [200, 206, 301, 302, 303, 307, 308]
30+
}

.github/workflows/ci.yml

Lines changed: 136 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,58 @@ permissions:
1414
contents: read
1515

1616
jobs:
17-
test:
17+
# Job pour détecter les changements dans différents types de fichiers
18+
detect-changes:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
python-changed: ${{ steps.changes.outputs.python }}
22+
javascript-changed: ${{ steps.changes.outputs.javascript }}
23+
docker-changed: ${{ steps.changes.outputs.docker }}
24+
docs-changed: ${{ steps.changes.outputs.docs }}
25+
config-changed: ${{ steps.changes.outputs.config }}
26+
steps:
27+
- name: Harden the runner (Audit all outbound calls)
28+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
29+
with:
30+
egress-policy: audit
31+
32+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
33+
34+
- uses: dorny/paths-filter@v3
35+
id: changes
36+
with:
37+
filters: |
38+
python:
39+
- '**/*.py'
40+
- 'pyproject.toml'
41+
- 'requirements*.txt'
42+
- 'tests/**'
43+
javascript:
44+
- '**/*.js'
45+
- '**/*.ts'
46+
- '**/*.jsx'
47+
- '**/*.tsx'
48+
- 'src/static/**'
49+
- 'eslint.config.cjs'
50+
- 'package*.json'
51+
docker:
52+
- 'Dockerfile*'
53+
- 'compose.yml'
54+
- '.docker/**'
55+
- '.dockerignore'
56+
docs:
57+
- '**/*.md'
58+
- 'docs/**'
59+
config:
60+
- '.github/**'
61+
- '.pre-commit-config.yaml'
62+
- 'renovate.json'
63+
64+
# Tests Python - exécutés seulement si du code Python a changé
65+
test-python:
1866
runs-on: ${{ matrix.os }}
67+
needs: detect-changes
68+
if: needs.detect-changes.outputs.python-changed == 'true' || needs.detect-changes.outputs.config-changed == 'true'
1969
strategy:
2070
fail-fast: false
2171
matrix:
@@ -57,12 +107,94 @@ jobs:
57107
if: ${{ matrix.coverage != true }}
58108
run: pytest
59109

60-
- name: Run tests
110+
- name: Run tests with coverage
61111
if: ${{ matrix.coverage == true }}
62-
run: pytest
112+
run: pytest --cov=src --cov-report=xml --cov-report=term
63113

114+
- name: Upload coverage to Codecov
115+
if: ${{ matrix.coverage == true }}
116+
uses: codecov/codecov-action@v4
117+
with:
118+
file: ./coverage.xml
119+
fail_ci_if_error: false
120+
121+
# Vérifications JavaScript/Static - exécutées seulement si des fichiers JS ont changé
122+
test-javascript:
123+
runs-on: ubuntu-latest
124+
needs: detect-changes
125+
if: needs.detect-changes.outputs.javascript-changed == 'true' || needs.detect-changes.outputs.config-changed == 'true'
126+
127+
steps:
128+
- name: Harden the runner (Audit all outbound calls)
129+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
130+
with:
131+
egress-policy: audit
64132

133+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
134+
135+
- name: Set up Node.js
136+
uses: actions/setup-node@v4
137+
with:
138+
node-version: '20'
139+
cache: 'npm'
140+
141+
- name: Install ESLint dependencies
142+
run: npm install eslint @eslint/js
143+
144+
- name: Run ESLint
145+
run: npx eslint src/static/js/**/*.js
146+
147+
# Pre-commit hooks - exécutés selon le type de changement
148+
pre-commit:
149+
runs-on: ubuntu-latest
150+
needs: detect-changes
151+
if: needs.detect-changes.outputs.python-changed == 'true' || needs.detect-changes.outputs.javascript-changed == 'true' || needs.detect-changes.outputs.config-changed == 'true'
152+
153+
steps:
154+
- name: Harden the runner (Audit all outbound calls)
155+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
156+
with:
157+
egress-policy: audit
158+
159+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
160+
161+
- name: Set up Python
162+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
163+
with:
164+
python-version: '3.13'
165+
cache: 'pip'
65166

66167
- name: Run pre-commit hooks
67168
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
68-
if: ${{ matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest' }}
169+
170+
# Job de résumé pour vérifier que tous les tests requis ont réussi
171+
test-summary:
172+
runs-on: ubuntu-latest
173+
needs: [detect-changes, test-python, test-javascript, pre-commit]
174+
if: always()
175+
steps:
176+
- name: Check test results
177+
run: |
178+
echo "Python tests needed: ${{ needs.detect-changes.outputs.python-changed }}"
179+
echo "JavaScript tests needed: ${{ needs.detect-changes.outputs.javascript-changed }}"
180+
echo "Python tests result: ${{ needs.test-python.result }}"
181+
echo "JavaScript tests result: ${{ needs.test-javascript.result }}"
182+
echo "Pre-commit result: ${{ needs.pre-commit.result }}"
183+
184+
# Vérifier que tous les jobs requis ont réussi ou ont été skippés
185+
if [[ "${{ needs.detect-changes.outputs.python-changed }}" == "true" && "${{ needs.test-python.result }}" != "success" ]]; then
186+
echo "Python tests failed"
187+
exit 1
188+
fi
189+
190+
if [[ "${{ needs.detect-changes.outputs.javascript-changed }}" == "true" && "${{ needs.test-javascript.result }}" != "success" ]]; then
191+
echo "JavaScript tests failed"
192+
exit 1
193+
fi
194+
195+
if [[ "${{ needs.pre-commit.result }}" == "failure" ]]; then
196+
echo "Pre-commit hooks failed"
197+
exit 1
198+
fi
199+
200+
echo "All required tests passed!"

.github/workflows/docker-build.ecr.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ on:
66
- 'main'
77
tags:
88
- '*'
9+
paths:
10+
- 'Dockerfile*'
11+
- 'compose.yml'
12+
- '.docker/**'
13+
- '.dockerignore'
14+
- 'src/**'
15+
- 'pyproject.toml'
16+
- 'requirements*.txt'
17+
- '.github/workflows/docker-build.ecr.yml'
918
merge_group:
1019
pull_request:
1120
types: [labeled, synchronize, reopened, ready_for_review, opened]

.github/workflows/docker-build.ghcr.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,27 @@ on:
66
- 'main'
77
tags:
88
- '*'
9+
paths:
10+
- 'Dockerfile*'
11+
- 'compose.yml'
12+
- '.docker/**'
13+
- '.dockerignore'
14+
- 'src/**'
15+
- 'pyproject.toml'
16+
- 'requirements*.txt'
17+
- '.github/workflows/docker-build.ghcr.yml'
918
merge_group:
1019
pull_request:
1120
types: [labeled, synchronize, reopened, ready_for_review, opened]
21+
paths:
22+
- 'Dockerfile*'
23+
- 'compose.yml'
24+
- '.docker/**'
25+
- '.dockerignore'
26+
- 'src/**'
27+
- 'pyproject.toml'
28+
- 'requirements*.txt'
29+
- '.github/workflows/docker-build.ghcr.yml'
1230

1331
concurrency:
1432
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}

.github/workflows/docs.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- '**/*.md'
8+
- 'docs/**'
9+
- '.github/workflows/docs.yml'
10+
pull_request:
11+
branches: [main]
12+
paths:
13+
- '**/*.md'
14+
- 'docs/**'
15+
- '.github/workflows/docs.yml'
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
lint-docs:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Harden the runner (Audit all outbound calls)
29+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
30+
with:
31+
egress-policy: audit
32+
33+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
34+
35+
- name: Install markdownlint-cli
36+
run: npm install -g markdownlint-cli
37+
38+
- name: Lint markdown files
39+
run: markdownlint '**/*.md' --ignore node_modules --ignore .git
40+
41+
- name: Check for broken links (if docs exist)
42+
if: hashFiles('docs/**') != ''
43+
run: |
44+
# Install markdown-link-check
45+
npm install -g markdown-link-check
46+
47+
# Check links in all markdown files
48+
find . -name "*.md" -not -path "./node_modules/*" -not -path "./.git/*" | \
49+
xargs -I {} markdown-link-check {} --config .github/markdown-link-check-config.json || true
50+
51+
check-spelling:
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Harden the runner (Audit all outbound calls)
55+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
56+
with:
57+
egress-policy: audit
58+
59+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
60+
61+
- name: Check spelling
62+
uses: crate-ci/typos@v1.16.26
63+
with:
64+
files: '*.md docs/'
65+
isolated: false

package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "gitingest",
3+
"version": "1.0.0",
4+
"description": "Git repository ingestion tool",
5+
"private": true,
6+
"scripts": {
7+
"lint:js": "eslint src/static/js/**/*.js",
8+
"lint:js:fix": "eslint src/static/js/**/*.js --fix"
9+
},
10+
"devDependencies": {
11+
"eslint": "^9.0.0",
12+
"@eslint/js": "^9.0.0"
13+
},
14+
"engines": {
15+
"node": ">=18.0.0"
16+
}
17+
}

0 commit comments

Comments
 (0)