Skip to content

Commit

Permalink
Merge pull request #115 from amplify-education/AT-8092-code-style-upd…
Browse files Browse the repository at this point in the history
…ates

Remove pycodestyle, add black, add numerous pre-commit checks.
  • Loading branch information
htorianik authored Jan 3, 2023
2 parents 31c1f07 + 43ca38a commit b3e81a9
Show file tree
Hide file tree
Showing 29 changed files with 274 additions and 4,961 deletions.
9 changes: 5 additions & 4 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
engines:
coverage:
enabled: true
excluded_paths:
- test/**
coverage:
enabled: true
excluded_paths:
- test/**
31 changes: 16 additions & 15 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
name: "CodeQL"
---
name: CodeQL

on:
push:
branches: [master, ]
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 18 * * 3'
- cron: 0 18 * * 3

jobs:
analyse:
name: Analyse
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -50,5 +51,5 @@ jobs:
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
37 changes: 19 additions & 18 deletions .github/workflows/pr_check.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Test
on:
pull_request:
Expand All @@ -7,21 +8,21 @@ on:
- synchronize

jobs:
test:
name: Check code against linter/unit tests
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install --upgrade "tox>=4.0.9,<5" build
- name: Build to generate the version file
run: python3 -m build
- name: Test with Tox
run: tox
test:
name: Check code against linter/unit tests
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install --upgrade "tox>=4.0.9,<5" build
- name: Build to generate the version file
run: python3 -m build
- name: Test with Tox
run: tox
59 changes: 30 additions & 29 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
---
name: Publish
on:
release:
types: [released]
release:
types: [released]

jobs:
build-publish:
name: Build and publish Python distributions
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@master
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: python -m pip install --upgrade pip build
- name: Generate Lark Parser
run: |
pip install -r requirements.txt -e .
python hcl2/parser.py
- name: Build tarball
run: python3 -m build
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
build-publish:
name: Build and publish Python distributions
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@master
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: python -m pip install --upgrade pip build
- name: Generate Lark Parser
run: |
pip install -r requirements.txt -e .
python hcl2/parser.py
- name: Build tarball
run: python3 -m build
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
45 changes: 45 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- id: no-commit-to-branch # Prevent commits directly to master
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
hooks:
- id: yamllint
name: Lint YAML
args: [--format, parsable, --strict]
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.2 # or specific tag
hooks:
- id: yamlfmt
args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '120']
- repo: https://github.com/executablebooks/mdformat.git
rev: 0.7.16
hooks:
- id: mdformat
name: Format markdown
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
language_version: python3.8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991 # Use the sha / tag you want to point at
hooks:
- id: mypy
- repo: local
hooks:
- id: pylint
name: pylint (Python Linting)
entry: pylint
language: system
types: [python]
files: ^(hcl2|test)/
args: [--rcfile=pylintrc, --output-format=colorized, --score=no]
12 changes: 0 additions & 12 deletions .remarkrc

This file was deleted.

8 changes: 8 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# https://yamllint.readthedocs.io/en/stable/configuration.html#extending-the-default-configuration

extends: relaxed
rules:
line-length:
max: 120
hyphens: disable
Loading

0 comments on commit b3e81a9

Please sign in to comment.