Skip to content

Commit 7ee536d

Browse files
authored
Merge pull request #8 from FlorianPfaff/fixlinterwarnings
Added GitHub action for linting
2 parents e35ae01 + 48982c5 commit 7ee536d

File tree

74 files changed

+2489
-985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2489
-985
lines changed

.bandit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
assert_used:
3+
skips: ["*.py"]

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 180

.github/workflows/mega-linter.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
# MegaLinter GitHub Action configuration file
3+
# More info at https://megalinter.io
4+
name: MegaLinter
5+
6+
permissions:
7+
checks: write
8+
pull-requests: write
9+
10+
on: # yamllint disable-line rule:truthy
11+
# Trigger mega-linter at every push. Action will also be visible from Pull Requests to main
12+
push: # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions)
13+
pull_request:
14+
branches: [master, main]
15+
16+
env: # Comment env block if you do not want to apply fixes
17+
# Apply linter fixes configuration
18+
APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool)
19+
APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all)
20+
APPLY_FIXES_MODE: commit # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request)
21+
22+
concurrency:
23+
group: ${{ github.ref }}-${{ github.workflow }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
build:
28+
name: MegaLinter
29+
runs-on: ubuntu-latest
30+
31+
permissions:
32+
checks: write
33+
pull-requests: write
34+
35+
steps:
36+
# Git Checkout
37+
- name: Checkout Code
38+
uses: actions/checkout@v3
39+
with:
40+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
41+
fetch-depth: 0 # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to improve performances
42+
43+
# MegaLinter
44+
- name: MegaLinter
45+
id: ml
46+
# You can override MegaLinter flavor used to have faster performances
47+
# More info at https://megalinter.io/flavors/
48+
uses: oxsecurity/megalinter@v6
49+
env:
50+
# All available variables are described in documentation
51+
# https://megalinter.io/configuration/
52+
VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
# ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
55+
# DISABLE: COPYPASTE,SPELL # Uncomment to disable copy-paste and spell checks
56+
57+
# Upload MegaLinter artifacts
58+
- name: Archive production artifacts
59+
if: ${{ success() }} || ${{ failure() }}
60+
uses: actions/upload-artifact@v3
61+
with:
62+
name: MegaLinter reports
63+
path: |
64+
megalinter-reports
65+
mega-linter.log
66+
67+
# Create pull request if applicable (for now works only on PR from same repository, not from forks)
68+
- name: Create Pull Request with applied fixes
69+
id: cpr
70+
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
71+
uses: peter-evans/create-pull-request@v5
72+
with:
73+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
74+
commit-message: "[MegaLinter] Apply linters automatic fixes"
75+
title: "[MegaLinter] Apply linters automatic fixes"
76+
labels: bot
77+
- name: Create PR output
78+
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
79+
run: |
80+
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
81+
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
82+
83+
# Push new commit if applicable (for now works only on PR from same repository, not from forks)
84+
- name: Prepare commit
85+
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
86+
run: sudo chown -Rc $UID .git/
87+
- name: Commit and push applied linter fixes
88+
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
89+
uses: stefanzweifel/git-auto-commit-action@v4
90+
with:
91+
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
92+
commit_message: "[MegaLinter] Apply linters fixes"
93+
commit_user_name: megalinter-bot
94+
commit_user_email: [email protected]

.github/workflows/publish.yml

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
1+
---
12
name: Create GitHub Release
23

3-
on:
4+
permissions:
5+
contents: write
6+
7+
on: # yamllint disable-line rule:truthy
48
push:
59
tags:
6-
- '*'
10+
- "*"
711

812
jobs:
913
build-and-release:
1014
runs-on: ubuntu-latest
1115
permissions:
1216
contents: write
1317
steps:
14-
- name: Check out repository
15-
uses: actions/checkout@v3
16-
17-
- name: Set up Python
18-
uses: actions/setup-python@v4
19-
with:
20-
python-version: '3.10.11'
21-
22-
- name: Install build dependencies
23-
run: python -m pip install --upgrade poetry
24-
25-
- name: Build package
26-
run: python -m poetry build
27-
28-
- name: Extract version from tag
29-
id: extract_version
30-
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
31-
32-
- name: Create GitHub Release and Upload Artifacts
33-
uses: ncipollo/release-action@v1
34-
with:
35-
tag: ${{ github.ref }}
36-
name: Release ${{ env.VERSION }}
37-
artifacts: ./dist/pyrecest-${{ env.VERSION }}-py3-none-any.whl,./dist/pyrecest-${{ env.VERSION }}.tar.gz
38-
token: ${{ secrets.GITHUB_TOKEN }}
18+
- name: Check out repository
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: "3.10.11"
25+
26+
- name: Install build dependencies
27+
run: python -m pip install --upgrade poetry
28+
29+
- name: Build package
30+
run: python -m poetry build
31+
32+
- name: Extract version from tag
33+
id: extract_version
34+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV"
35+
36+
- name: Create GitHub Release and Upload Artifacts
37+
uses: ncipollo/release-action@v1
38+
with:
39+
tag: ${{ github.ref }}
40+
name: Release ${{ env.VERSION }}
41+
artifacts: ./dist/pyrecest-${{ env.VERSION }}-py3-none-any.whl,./dist/pyrecest-${{ env.VERSION }}.tar.gz
42+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
---
12
name: Test Workflow
23

3-
on:
4+
permissions: read-all
5+
6+
on: # yamllint disable-line rule:truthy
47
push:
58
branches:
69
- main
@@ -16,36 +19,30 @@ jobs:
1619
pull-requests: write
1720

1821
steps:
19-
- name: Check out repository
20-
uses: actions/checkout@v3
21-
22-
- name: Set up Miniconda
23-
uses: conda-incubator/setup-miniconda@v2
24-
with:
25-
activate-environment: pyRecEst
26-
environment-file: environment.yml
27-
auto-activate-base: false
28-
29-
- name: List files and check Python version
30-
shell: bash -l {0}
31-
run: |
32-
ls -al
33-
python -c 'import sys; print(sys.version_info[:])'
34-
35-
- name: Run tests
36-
shell: bash -l {0}
37-
env:
22+
- name: Check out repository
23+
uses: actions/checkout@v3
24+
25+
- name: Set up Miniconda
26+
uses: conda-incubator/setup-miniconda@v2
27+
with:
28+
activate-environment: pyRecEst
29+
environment-file: environment.yml
30+
auto-activate-base: false
31+
32+
- name: List files and check Python version
33+
shell: bash -l {0}
34+
run: |
35+
ls -al
36+
python -c 'import sys; print(sys.version_info[:])'
37+
38+
- name: Run tests
39+
shell: bash -l {0}
40+
env:
3841
PYTHONPATH: ${{ github.workspace }}
39-
run: pytest --rootdir . -v --strict-config --junitxml=junit_test_results.xml ./pyrecest
40-
41-
- name: Publish test results
42-
if: always()
43-
uses: EnricoMi/publish-unit-test-result-action@v2
44-
with:
45-
files: junit_test_results.xml
46-
47-
- name: Produce error on failure
48-
if: ${{ failure() }}
49-
run: |
50-
echo "Tests failed."
51-
exit 1
42+
run: pytest --rootdir . -v --strict-config --junitxml=junit_test_results.xml ./pyrecest
43+
44+
- name: Publish test results
45+
if: always()
46+
uses: EnricoMi/publish-unit-test-result-action@v2
47+
with:
48+
files: junit_test_results.xml

.gitignore

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,124 @@ cython_debug/
162162
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
163163
# and can be added to the global gitignore or merged into this file. For a more nuclear
164164
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
165-
#.idea/
165+
#.idea/
166+
167+
# Mega linter
168+
# Logs
169+
logs
170+
*.log
171+
npm-debug.log*
172+
yarn-debug.log*
173+
yarn-error.log*
174+
/package-lock.json
175+
176+
# Runtime data
177+
pids
178+
*.pid
179+
*.seed
180+
*.pid.lock
181+
182+
# Directory for instrumented libs generated by jscoverage/JSCover
183+
lib-cov
184+
185+
# Coverage directory used by tools like istanbul
186+
coverage
187+
188+
# nyc test coverage
189+
.nyc_output
190+
191+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
192+
.grunt
193+
194+
# Bower dependency directory (https://bower.io/)
195+
bower_components
196+
197+
# node-waf configuration
198+
.lock-wscript
199+
200+
# Compiled binary add-ons (https://nodejs.org/api/addons.html)
201+
build/Release
202+
203+
# Dependency directories
204+
node_modules/
205+
jspm_packages/
206+
207+
# TypeScript v1 declaration files
208+
typings/
209+
210+
# Optional npm cache directory
211+
.npm
212+
213+
# Optional eslint cache
214+
.eslintcache
215+
216+
# Optional REPL history
217+
.node_repl_history
218+
219+
# Output of 'npm pack'
220+
*.tgz
221+
222+
# Yarn Integrity file
223+
.yarn-integrity
224+
225+
# dotenv environment variables file
226+
.env
227+
228+
# next.js build output
229+
.next
230+
231+
# clj-kondo cache
232+
.cache
233+
234+
# default output report
235+
mega-linter.report
236+
237+
__pycache__/
238+
239+
.idea/
240+
241+
# Git directory (useful for .dockerignore)
242+
.git
243+
244+
.automation/test/arm/arm-ttk/
245+
246+
.coverage
247+
248+
coverage.xml
249+
250+
.coverage*
251+
252+
.automation/test/rust/bad/target/
253+
254+
.automation/test/rust/bad/Cargo.lock
255+
256+
.automation/test/rust/good/target/
257+
258+
.automation/test/rust/good/Cargo.lock
259+
260+
.automation/test/copypaste/bad/report/
261+
262+
.automation/test/copypaste/good/report/
263+
264+
**/megalinter-reports/*
265+
!**/salesforce/report/*
266+
!**/salesforce/good/report/*
267+
!**/salesforce/bad/report/*
268+
269+
site/
270+
271+
.sfdx/
272+
273+
.vscode/settings.json
274+
275+
megalinter-reports/
276+
277+
github_conf/
278+
279+
Pipfile
280+
281+
# .NET Core build folders
282+
bin/
283+
obj/
284+
285+
run_local_linter.sh

0 commit comments

Comments
 (0)