Skip to content

Commit

Permalink
feat: move last SuperLinter check yamllint to pre-commit (#124)
Browse files Browse the repository at this point in the history
This also removes SuperLinter from DGP since all utilized checks have
been migrated to pre-commit.
  • Loading branch information
tk-woven authored Aug 23, 2022
1 parent f377eb4 commit 889d8b6
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .commitlintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
extends:
- '@commitlint/config-conventional'
rules:
type-enum: [2, 'always', ['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'refactor', 'revert', 'perf', 'schema', 'style', 'test']]
type-enum: [2, 'always', ['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'refactor', 'revert', 'perf', 'schema', 'style', 'test']]
2 changes: 1 addition & 1 deletion .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}-${{ github.sha }},${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
116 changes: 58 additions & 58 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,61 +15,61 @@ jobs:
PYTHON: '3.9'
COVERAGE_TOTAL: 49 # Coverage threshold percentage
steps:
- name: Checkout (admin token)
if: ${{github.event_name != 'pull_request'}} # We don't want to use the admin token for PR flows
uses: actions/checkout@master
with:
token: '${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}'
fetch-depth: "2" # Original commit + code cov badge commit
- name: Checkout (normal flow)
if: ${{github.event_name == 'pull_request'}}
uses: actions/checkout@master
with:
fetch-depth: "2" # Original commit + code cov badge commit
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: 3.9
- name: Install dependencies
id: coverage-installer
run: |
python -m pip install --upgrade pip
pip install cython==0.29.21 numpy==1.23.2
sudo apt-get install jq
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install coverage-badge
- name: Run tests and calculate coverage
id: test-runner
run: |
coverage run -m pytest
coverage-badge -f -o docs/coverage.svg
COVERAGE_SCORE=$(coverage json -o /dev/stdout | jq .totals.percent_covered)
echo "::set-output name=coverageScore::$COVERAGE_SCORE"
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v6
id: changed_files
with:
files: docs/coverage.svg
- name: Commit code coverage badge
if: ${{ steps.changed_files.outputs.files_changed == 'true' && github.event_name != 'pull_request'}}
run: |
git config --local user.name "$(git log -1 --pretty=format:'%an' | xargs)"
git config --local user.email "$(git log -1 --pretty=format:'%ae' | xargs)"
git add docs/coverage.svg
git commit -m "test: update coverage.svg"
git reset --soft HEAD~2
# shellcheck disable=SC1083 # code is irrelevant because git needs this literal
git commit -m "$(git log --format=%B --reverse HEAD..HEAD@{1})"
- name: Push code coverage badge
if: ${{ steps.changed_files.outputs.files_changed == 'true' && github.event_name != 'pull_request'}}
uses: ad-m/github-push-action@master
with:
force: true
github_token: ${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}
branch: ${{ github.event.pull_request.head.repo.full_name }}
- name: Coverage total fail - exit
if: ${{github.event_name == 'pull_request' && steps.test-runner.outputs.coverageScore < env.COVERAGE_TOTAL}}
run: |
echo "cov total fail ${{ steps.test-runner.outputs.coverageScore }}"
exit 1
- name: Checkout (admin token)
if: ${{github.event_name != 'pull_request'}} # We don't want to use the admin token for PR flows
uses: actions/checkout@master
with:
token: '${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}'
fetch-depth: "2" # Original commit + code cov badge commit
- name: Checkout (normal flow)
if: ${{github.event_name == 'pull_request'}}
uses: actions/checkout@master
with:
fetch-depth: "2" # Original commit + code cov badge commit
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: 3.9
- name: Install dependencies
id: coverage-installer
run: |
python -m pip install --upgrade pip
pip install cython==0.29.21 numpy==1.23.2
sudo apt-get install jq
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install coverage-badge
- name: Run tests and calculate coverage
id: test-runner
run: |
coverage run -m pytest
coverage-badge -f -o docs/coverage.svg
COVERAGE_SCORE=$(coverage json -o /dev/stdout | jq .totals.percent_covered)
echo "::set-output name=coverageScore::$COVERAGE_SCORE"
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v6
id: changed_files
with:
files: docs/coverage.svg
- name: Commit code coverage badge
if: ${{ steps.changed_files.outputs.files_changed == 'true' && github.event_name != 'pull_request'}}
run: |
git config --local user.name "$(git log -1 --pretty=format:'%an' | xargs)"
git config --local user.email "$(git log -1 --pretty=format:'%ae' | xargs)"
git add docs/coverage.svg
git commit -m "test: update coverage.svg"
git reset --soft HEAD~2
# shellcheck disable=SC1083 # code is irrelevant because git needs this literal
git commit -m "$(git log --format=%B --reverse HEAD..HEAD@{1})"
- name: Push code coverage badge
if: ${{ steps.changed_files.outputs.files_changed == 'true' && github.event_name != 'pull_request'}}
uses: ad-m/github-push-action@master
with:
force: true
github_token: ${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}
branch: ${{ github.event.pull_request.head.repo.full_name }}
- name: Coverage total fail - exit
if: ${{github.event_name == 'pull_request' && steps.test-runner.outputs.coverageScore < env.COVERAGE_TOTAL}}
run: |
echo "cov total fail ${{ steps.test-runner.outputs.coverageScore }}"
exit 1
44 changes: 22 additions & 22 deletions .github/workflows/doc-gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ jobs:
OS: ubuntu-20.04
PYTHON: '3.9'
steps:
- uses: actions/checkout@master
with:
fetch-depth: "1"
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: 3.9
- name: Setup requirements and run sphinx
run: |
python -m pip install --upgrade pip
pip install cython==0.29.21 numpy==1.23.2
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install -r docs/requirements-doc.txt
cd docs
make html
- name: Push Sphinx Pages to Webserver
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: ./docs/build/html
commit-message: 'docs: update build documentation'
- uses: actions/checkout@master
with:
fetch-depth: "1"
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: 3.9
- name: Setup requirements and run sphinx
run: |
python -m pip install --upgrade pip
pip install cython==0.29.21 numpy==1.23.2
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install -r docs/requirements-doc.txt
cd docs
make html
- name: Push Sphinx Pages to Webserver
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: ./docs/build/html
commit-message: 'docs: update build documentation'
23 changes: 0 additions & 23 deletions .github/workflows/pre-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,3 @@ jobs:
run: |
pre-commit install
pre-commit run --all-files
- name: Lint code base with SuperLinter
# Documentation: https://github.com/github/super-linter#how-to-use
uses: github/super-linter@v4
env:
DEFAULT_BRANCH: master
FILTER_REGEX_EXCLUDE: .*pb2*py
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: .
VALIDATE_ALL_CODEBASE: false # Only new or edited files will be parsed for validation.
VALIDATE_DOCKERFILE_HADOLINT: false
VALIDATE_GITLEAKS: false # Handled by pre-commit.
VALIDATE_HTML: false # Handled by pre-commit.
VALIDATE_JSCPD: false
VALIDATE_JSON: false # Handled by pre-commit.
VALIDATE_MARKDOWN: false # Handled by pre-commit.
VALIDATE_NATURAL_LANGUAGE: false # No corresponding pre-commit hook but not critical.
VALIDATE_PROTOBUF: false
VALIDATE_PYTHON_BLACK: false
VALIDATE_PYTHON_FLAKE8: false # Formatted by YAPF.
VALIDATE_PYTHON_ISORT: false # Formatted by YAPF.
VALIDATE_PYTHON_MYPY: false
VALIDATE_PYTHON_PYLINT: false # Handled by pre-commit.
VALIDATE_SHELL_SHFMT: false # Handled by pre-commit.
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ repos:
hooks:
- id: shellcheck
- id: shfmt
- repo: https://github.com/adrienverge/yamllint
rev: v1.27.1
hooks:
- id: yamllint
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.32.0
hooks:
Expand Down
8 changes: 8 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extends: default

rules:
line-length: disable
document-start: disable # Allow missing "---" file prelude.
truthy:
check-keys: false # Allow keys that look like truthy literals, such as `on`.
comments: disable # Allow single space between non-comment and comment.

0 comments on commit 889d8b6

Please sign in to comment.