-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f482484
commit c9751e4
Showing
3 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Generate Changelog | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: [merged] | ||
jobs: | ||
generate-changelog: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Generate CHANGELOG.md | ||
run: | | ||
git fetch origin dev | ||
commits=$(git log --pretty=format:"* %s" origin/dev..HEAD) | ||
echo "# Changelog" > CHANGELOG.md | ||
echo "" >> CHANGELOG.md | ||
echo "## Unreleased" >> CHANGELOG.md | ||
echo "" >> CHANGELOG.md | ||
echo "$commits" >> CHANGELOG.md | ||
- name: Commit and push changes | ||
run: | | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
git add CHANGELOG.md | ||
git commit -m "Update CHANGELOG.md" | ||
git push origin main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: SelfHosted Tester | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
continue-on-error: true | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip setuptools wheel | ||
pip install --no-deps -r requirements.txt | ||
continue-on-error: true | ||
|
||
- name: Run tests | ||
run: | | ||
pytest app.py | ||
continue-on-error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
name: Pylint | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'app.py' | ||
- 'requirements.txt' | ||
- '.github/workflows/pylint.yml' | ||
pull_request: | ||
paths: | ||
- 'app.py' | ||
- 'requirements.txt' | ||
- '.github/workflows/pylint.yml' | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
cache: 'pip' | ||
cache-dependency-path: | | ||
requirements.txt | ||
- name: Create virtual environment | ||
run: | | ||
python -m venv venv | ||
source venv/bin/activate | ||
- name: Install base dependencies | ||
run: | | ||
python -m pip install --upgrade pip setuptools wheel | ||
pip install pylint black flake8 mypy | ||
- name: Install project dependencies | ||
run: | | ||
# Installing main requirements | ||
pip install --no-deps -r requirements.txt | ||
continue-on-error: true | ||
|
||
- name: Create .pylintrc | ||
run: | | ||
cat > .pylintrc << EOF | ||
[MASTER] | ||
ignore=venv | ||
persistent=yes | ||
[MESSAGES CONTROL] | ||
disable=\ | ||
C0111, # missing-docstring | ||
C0103, # invalid-name | ||
C0301, # line-too-long | ||
C0114, # missing-module-docstring | ||
C0115, # missing-class-docstring | ||
C0116, # missing-function-docstring | ||
R0913, # too-many-arguments | ||
R0914, # too-many-locals | ||
W0611, # unused-import | ||
W0401, # wildcard-import | ||
W0614, # unused-wildcard-import | ||
W0703, # broad-except | ||
E1101, # no-member (often false-positives) | ||
[FORMAT] | ||
max-line-length=120 | ||
[BASIC] | ||
good-names=i,j,k,ex,Run,_,fp,id | ||
[MISCELLANEOUS] | ||
notes=FIXME,XXX,TODO | ||
[SIMILARITIES] | ||
min-similarity-lines=4 | ||
ignore-comments=yes | ||
ignore-docstrings=yes | ||
ignore-imports=yes | ||
EOF | ||
- name: Run black check | ||
run: | | ||
black --check --diff LaunchFile/ | ||
continue-on-error: true | ||
|
||
- name: Run pylint | ||
run: | | ||
mkdir -p ./reports | ||
pylint LaunchFile/ --output-format=json > ./reports/pylint-report.json || true | ||
pylint LaunchFile/ --output-format=text > ./reports/pylint-report.txt || true | ||
continue-on-error: true | ||
|
||
- name: Run flake8 | ||
run: | | ||
flake8 LaunchFile/ --max-line-length=120 --statistics --tee --output-file=./reports/flake8-report.txt || true | ||
continue-on-error: true | ||
|
||
- name: Check pylint score | ||
run: | | ||
SCORE=$(tail -n 2 ./reports/pylint-report.txt | grep -oP "(?<=rated at )[0-9.]+") | ||
echo "Pylint score: $SCORE/10" | ||
if (( $(echo "$SCORE < 7.0" | bc -l) )); then | ||
echo "Warning: Pylint score is below 7.0" | ||
exit 1 | ||
fi | ||
- name: Run MyPy | ||
run: | | ||
source venv/bin/activate | ||
mypy LaunchFile/ | ||
continue-on-error: true | ||
|
||
- name: Run tests | ||
run: | | ||
source venv/bin/activate | ||
python -m unittest discover -s tests || true | ||
continue-on-error: true | ||
|
||
- name: Upload lint results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: lint-reports | ||
path: | | ||
./reports/pylint-report.json | ||
./reports/pylint-report.txt | ||
./reports/flake8-report.txt | ||
retention-days: 14 | ||
|
||
- name: Comment PR with lint results | ||
if: github.event_name == 'pull_request' && always() | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const pylintReport = fs.readFileSync('./reports/pylint-report.txt', 'utf8'); | ||
const score = pylintReport.match(/rated at ([0-9.]+)/); | ||
const scoreValue = score ? score[1] : 'N/A'; | ||
const body = `## Lint Results | ||
### Pylint Score: ${scoreValue}/10 | ||
<details> | ||
<summary>Detailed Report</summary> | ||
\`\`\` | ||
${pylintReport} | ||
\`\`\` | ||
</details>`; | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: body | ||
}); |