|
8 | 8 | branches: [ main ] |
9 | 9 | push: |
10 | 10 | branches: [ main ] |
11 | | - workflow_dispatch: |
| 11 | + workflow_dispatch: {} |
12 | 12 |
|
13 | 13 | jobs: |
14 | | - lint-python: |
15 | | - name: Lint Python Files |
16 | | - runs-on: ubuntu-latest |
17 | | - permissions: |
18 | | - contents: read |
19 | | - steps: |
20 | | - - name: Checkout repository |
21 | | - uses: actions/checkout@v5 |
22 | | - |
23 | | - - name: Setup Python |
24 | | - uses: actions/setup-python@v6 |
25 | | - with: |
26 | | - python-version: '3.11' |
27 | | - |
28 | | - - name: Install linting tools |
29 | | - run: | |
30 | | - python -m pip install --upgrade pip |
31 | | - pip install pylint black mypy flake8 |
32 | | -
|
33 | | - - name: Run Black (Format Check) |
34 | | - run: | |
35 | | - echo "Running Black format check..." |
36 | | - black --check --diff update_badges.py || echo "Black check completed with warnings" |
37 | | -
|
38 | | - - name: Run Pylint |
39 | | - run: | |
40 | | - echo "Running Pylint..." |
41 | | - pylint --max-line-length=100 --disable=C0114,C0115,C0116 update_badges.py || echo "Pylint completed with warnings" |
42 | | - continue-on-error: true |
43 | | - |
44 | | - - name: Run MyPy |
45 | | - run: | |
46 | | - echo "Running MyPy..." |
47 | | - mypy --ignore-missing-imports update_badges.py || echo "MyPy completed with warnings" |
48 | | - continue-on-error: true |
49 | | - |
50 | | - - name: Run Flake8 |
51 | | - run: | |
52 | | - echo "Running Flake8..." |
53 | | - flake8 --max-line-length=100 --ignore=E501,W503 update_badges.py || echo "Flake8 completed with warnings" |
54 | | - continue-on-error: true |
55 | | - |
56 | 14 | lint-yaml: |
57 | 15 | name: Lint YAML Files |
58 | 16 | runs-on: ubuntu-latest |
@@ -83,121 +41,3 @@ jobs: |
83 | 41 | echo "Validating action.yml syntax..." |
84 | 42 | python -c "import yaml; yaml.safe_load(open('action.yml'))" && echo "✓ action.yml is valid YAML" |
85 | 43 |
|
86 | | - test-update-badges: |
87 | | - name: Test update_badges.py |
88 | | - runs-on: ubuntu-latest |
89 | | - permissions: |
90 | | - contents: read |
91 | | - steps: |
92 | | - - name: Checkout repository |
93 | | - uses: actions/checkout@v5 |
94 | | - |
95 | | - - name: Setup Python |
96 | | - uses: actions/setup-python@v6 |
97 | | - with: |
98 | | - python-version: '3.11' |
99 | | - |
100 | | - - name: Test script help |
101 | | - run: | |
102 | | - python3 update_badges.py --help |
103 | | -
|
104 | | - - name: Test script with mock data |
105 | | - run: | |
106 | | - # Create test environment |
107 | | - mkdir -p test_badges |
108 | | - cat > test_readme.md << 'EOF' |
109 | | - # Test Project |
110 | | - |
111 | | - Some content here. |
112 | | - EOF |
113 | | - |
114 | | - # Create dummy badge files |
115 | | - echo '<svg></svg>' > test_badges/pylint.svg |
116 | | - echo '<svg></svg>' > test_badges/black.svg |
117 | | - echo '<svg></svg>' > test_badges/mypy.svg |
118 | | - |
119 | | - # Test with relative paths |
120 | | - python3 update_badges.py \ |
121 | | - --readme test_readme.md \ |
122 | | - --badges-dir test_badges |
123 | | - |
124 | | - # Verify output |
125 | | - if ! grep -q "linting-badges-start" test_readme.md; then |
126 | | - echo "Error: Script did not update README" |
127 | | - exit 1 |
128 | | - fi |
129 | | - |
130 | | - echo "✓ update_badges.py test passed" |
131 | | - cat test_readme.md |
132 | | -
|
133 | | - shellcheck: |
134 | | - name: Shellcheck |
135 | | - runs-on: ubuntu-latest |
136 | | - permissions: |
137 | | - contents: read |
138 | | - steps: |
139 | | - - name: Checkout repository |
140 | | - uses: actions/checkout@v5 |
141 | | - |
142 | | - - name: Run shellcheck on embedded scripts |
143 | | - run: | |
144 | | - echo "Checking shell scripts in action.yml..." |
145 | | - # Extract and check shell scripts from action.yml if needed |
146 | | - # For now, just verify bash syntax on key commands |
147 | | - bash -n -c 'pip3 install pylint black mypy' || echo "Shell syntax check passed" |
148 | | -
|
149 | | - security-scan: |
150 | | - name: Security Scan |
151 | | - runs-on: ubuntu-latest |
152 | | - permissions: |
153 | | - contents: read |
154 | | - steps: |
155 | | - - name: Checkout repository |
156 | | - uses: actions/checkout@v5 |
157 | | - |
158 | | - - name: Setup Python |
159 | | - uses: actions/setup-python@v6 |
160 | | - with: |
161 | | - python-version: '3.11' |
162 | | - |
163 | | - - name: Install security tools |
164 | | - run: | |
165 | | - python -m pip install --upgrade pip |
166 | | - pip install safety bandit |
167 | | -
|
168 | | - - name: Run bandit (Python security scan) |
169 | | - run: | |
170 | | - echo "Running bandit security scan..." |
171 | | - bandit -r update_badges.py -ll || echo "Bandit scan completed" |
172 | | - continue-on-error: true |
173 | | - |
174 | | - - name: Run safety (dependency vulnerability check) |
175 | | - run: | |
176 | | - echo "Running safety check..." |
177 | | - # Create a requirements file for scanning |
178 | | - pip freeze > installed_requirements.txt |
179 | | - safety check -r installed_requirements.txt || echo "Safety check completed" |
180 | | - continue-on-error: true |
181 | | - |
182 | | - test-summary: |
183 | | - name: All Checks Complete |
184 | | - runs-on: ubuntu-latest |
185 | | - permissions: |
186 | | - contents: read |
187 | | - needs: |
188 | | - - lint-python |
189 | | - - lint-yaml |
190 | | - - test-update-badges |
191 | | - - shellcheck |
192 | | - - security-scan |
193 | | - steps: |
194 | | - - name: Summary |
195 | | - run: | |
196 | | - echo "✅ All linting and testing checks completed!" |
197 | | - echo "" |
198 | | - echo "Checks performed:" |
199 | | - echo " ✓ Python linting (Black, Pylint, MyPy, Flake8)" |
200 | | - echo " ✓ YAML linting" |
201 | | - echo " ✓ update_badges.py functionality test" |
202 | | - echo " ✓ Shell script syntax check" |
203 | | - echo " ✓ Security scanning (Bandit, Safety)" |
0 commit comments