diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 48e226b..5bb8e67 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -12,9 +12,16 @@ updates: schedule: interval: "weekly" ignore: + # Managed by cisagov/skeleton-generic - dependency-name: actions/cache - dependency-name: actions/checkout + - dependency-name: actions/setup-go - dependency-name: actions/setup-python + - dependency-name: hashicorp/setup-terraform + - dependency-name: mxschmitt/action-tmate + # # Managed by cisagov/skeleton-python-library + # - dependency-name: actions/download-artifact + # - dependency-name: actions/upload-artifact - package-ecosystem: "pip" directory: "/" diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..7cdfd79 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,70 @@ +--- +# Rather than breaking up descriptions into multiline strings we disable that +# specific rule in yamllint for this file. +# yamllint disable rule:line-length +- color: "eb6420" + description: This issue or pull request is awaiting the outcome of another issue or pull request + name: blocked +- color: "000000" + description: This issue or pull request involves changes to existing functionality + name: breaking change +- color: "d73a4a" + description: This issue or pull request addresses broken functionality + name: bug +- color: "07648d" + description: This issue will be advertised on code.gov's Open Tasks page (https://code.gov/open-tasks) + name: code.gov +- color: "0366d6" + description: Pull requests that update a dependency file + name: dependencies +- color: "5319e7" + description: This issue or pull request improves or adds to documentation + name: documentation +- color: "cfd3d7" + description: This issue or pull request already exists or is covered in another issue or pull request + name: duplicate +- color: "b005bc" + description: A high-level objective issue encompassing multiple issues instead of a specific unit of work + name: epic +- color: "000000" + description: Pull requests that update GitHub Actions code + name: github-actions +- color: "0e8a16" + description: This issue or pull request is well-defined and good for newcomers + name: good first issue +- color: "ff7518" + description: Pull request that should count toward Hacktoberfest participation + name: hacktoberfest-accepted +- color: "a2eeef" + description: This issue or pull request will add or improve functionality, maintainability, or ease of use + name: improvement +- color: "fef2c0" + description: This issue or pull request is not applicable, incorrect, or obsolete + name: invalid +- color: "ce099a" + description: This pull request is ready to merge during the next Lineage Kraken release + name: kraken 🐙 +- color: "a4fc5d" + description: This issue or pull request requires further information + name: need info +- color: "fcdb45" + description: This pull request is awaiting an action or decision to move forward + name: on hold +- color: "3772a4" + description: Pull requests that update Python code + name: python +- color: "ef476c" + description: This issue is a request for information or needs discussion + name: question +- color: "00008b" + description: This issue or pull request adds or otherwise modifies test code + name: test +- color: "1d76db" + description: This issue or pull request pulls in upstream updates + name: upstream update +- color: "d4c5f9" + description: This issue or pull request increments the version number + name: version bump +- color: "ffffff" + description: This issue will not be incorporated + name: wontfix diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66c72a7..4d7ae12 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,28 +21,24 @@ jobs: uses: cisagov/setup-env-github-action@develop - uses: actions/checkout@v3 - id: setup-python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: "3.10" # We need the Go version and Go cache location for the actions/cache step, # so the Go installation must happen before that. - - uses: actions/setup-go@v2 + - id: setup-go + uses: actions/setup-go@v3 with: - go-version: "1.16" - - name: Store installed Go version - id: go-version - run: | - echo "::set-output name=version::"\ - "$(go version | sed 's/^go version go\([0-9.]\+\) .*/\1/')" + go-version: "1.19" - name: Lookup Go cache directory id: go-cache run: | - echo "::set-output name=dir::$(go env GOCACHE)" + echo "dir=$(go env GOCACHE)" >> $GITHUB_OUTPUT - uses: actions/cache@v3 env: BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\ py${{ steps.setup-python.outputs.python-version }}-\ - go${{ steps.go-version.outputs.version }}-\ + go${{ steps.setup-go.outputs.go-version }}-\ packer${{ steps.setup-env.outputs.packer-version }}-\ tf${{ steps.setup-env.outputs.terraform-version }}-" with: @@ -82,7 +78,7 @@ jobs: ${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}" sudo mv /usr/local/bin/packer /usr/local/bin/packer-default sudo ln -s /opt/packer/packer /usr/local/bin/packer - - uses: hashicorp/setup-terraform@v1 + - uses: hashicorp/setup-terraform@v2 with: terraform_version: ${{ steps.setup-env.outputs.terraform-version }} - name: Install shfmt @@ -107,16 +103,28 @@ jobs: uses: mxschmitt/action-tmate@v3 if: env.RUN_TMATE test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: + os: + - ubuntu-latest python-version: +<<<<<<< HEAD +======= + - "3.7" + - "3.8" + - "3.9" +>>>>>>> 65604c7e134491f497f612f6eaebded8f411bec5 - "3.10" + - "3.11" + include: + - os: ubuntu-20.04 + python-version: "3.6" steps: - uses: actions/checkout@v3 - id: setup-python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - uses: actions/cache@v3 @@ -155,11 +163,12 @@ jobs: if: env.RUN_TMATE coveralls-finish: runs-on: ubuntu-latest - needs: test + needs: + - test steps: - uses: actions/checkout@v3 - id: setup-python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: "3.10" - uses: actions/cache@v3 @@ -189,17 +198,31 @@ jobs: uses: mxschmitt/action-tmate@v3 if: env.RUN_TMATE build: - runs-on: ubuntu-latest - needs: [lint, test] + runs-on: ${{ matrix.os }} + needs: + - lint + - test strategy: fail-fast: false matrix: + os: + - ubuntu-latest python-version: +<<<<<<< HEAD +======= + - "3.7" + - "3.8" + - "3.9" +>>>>>>> 65604c7e134491f497f612f6eaebded8f411bec5 - "3.10" + - "3.11" + include: + - os: ubuntu-20.04 + python-version: "3.6" steps: - uses: actions/checkout@v3 - id: setup-python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - uses: actions/cache@v3 @@ -223,10 +246,65 @@ jobs: - name: Build artifacts run: python -m build - name: Upload artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: dist-${{ matrix.python-version }} path: dist - name: Setup tmate debug session uses: mxschmitt/action-tmate@v3 if: env.RUN_TMATE + test-build: + runs-on: ${{ matrix.os }} + needs: + - build + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + python-version: + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "3.11" + include: + - os: ubuntu-20.04 + python-version: "3.6" + steps: + - uses: actions/checkout@v3 + - id: setup-python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/cache@v3 + env: + BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\ + py${{ steps.setup-python.outputs.python-version }}-" + with: + path: ${{ env.PIP_CACHE_DIR }} + # We do not use '**/setup.py' in the cache key so only the 'setup.py' + # file in the root of the repository is used. This is in case a Python + # package were to have a 'setup.py' as part of its internal codebase. + key: "${{ env.BASE_CACHE_KEY }}\ + ${{ hashFiles('**/requirements.txt') }}-\ + ${{ hashFiles('setup.py') }}" + restore-keys: | + ${{ env.BASE_CACHE_KEY }} + - name: Retrieve the built wheel + uses: actions/download-artifact@v3 + with: + name: dist-${{ matrix.python-version }} + - name: Install testing dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install --upgrade pytest pytest-cov + - name: Install the built wheel (there should only be one) + run: python -m pip install *.whl + - name: Run tests + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + run: pytest + - name: Setup tmate debug session + uses: mxschmitt/action-tmate@v3 + if: env.RUN_TMATE diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml new file mode 100644 index 0000000..ae7c091 --- /dev/null +++ b/.github/workflows/sync-labels.yml @@ -0,0 +1,29 @@ +--- +name: sync-labels + +on: + push: + paths: + - '.github/labels.yml' + - '.github/workflows/sync-labels.yml' + +permissions: + contents: read + +jobs: + labeler: + permissions: + # actions/checkout needs this to fetch code + contents: read + # crazy-max/ghaction-github-labeler needs this to manage repository labels + issues: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Sync repository labels + if: success() + uses: crazy-max/ghaction-github-labeler@v4 + with: + # This is a hideous ternary equivalent so we only do a dry run unless + # this workflow is triggered by the develop branch. + dry-run: ${{ github.ref_name == 'develop' && 'false' || 'true' }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0fd3c2b..83ef73f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ default_language_version: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.3.0 hooks: - id: check-case-conflict - id: check-executables-have-shebangs @@ -31,17 +31,17 @@ repos: # Text file hooks - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.31.1 + rev: v0.32.2 hooks: - id: markdownlint args: - --config=.mdl_config.yaml - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.6.1 + rev: v3.0.0-alpha.4 hooks: - id: prettier - repo: https://github.com/adrienverge/yamllint - rev: v1.26.3 + rev: v1.28.0 hooks: - id: yamllint args: @@ -49,14 +49,14 @@ repos: # GitHub Actions hooks - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.14.2 + rev: 0.18.4 hooks: - id: check-github-actions - id: check-github-workflows # pre-commit hooks - repo: https://github.com/pre-commit/pre-commit - rev: v2.17.0 + rev: v2.20.0 hooks: - id: validate_manifest @@ -81,7 +81,7 @@ repos: - id: shell-lint # Python hooks - # Run bandit on "tests" tree with a configuration + # Run bandit on the "tests" tree with a configuration - repo: https://github.com/PyCQA/bandit rev: 1.7.4 hooks: @@ -90,21 +90,26 @@ repos: files: tests args: - --config=.bandit.yml - # Run bandit everything but tests directory + # Run bandit on everything except the "tests" tree - repo: https://github.com/PyCQA/bandit - rev: 1.7.0 + rev: 1.7.4 hooks: - id: bandit name: bandit (everything else) exclude: tests - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.10.0 hooks: - id: black +<<<<<<< HEAD args: - --target-version=py310 - repo: https://gitlab.com/pycqa/flake8 rev: 3.9.2 +======= + - repo: https://github.com/PyCQA/flake8 + rev: 5.0.4 +>>>>>>> 65604c7e134491f497f612f6eaebded8f411bec5 hooks: - id: flake8 additional_dependencies: @@ -114,7 +119,7 @@ repos: hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.942 + rev: v0.990 hooks: - id: mypy additional_dependencies: @@ -123,7 +128,7 @@ repos: - types-PyYAML - types-setuptools - repo: https://github.com/asottile/pyupgrade - rev: v2.31.1 + rev: v3.2.0 hooks: - id: pyupgrade @@ -136,14 +141,14 @@ repos: # Terraform hooks - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.64.0 + rev: v1.76.0 hooks: - id: terraform_fmt - id: terraform_validate # Docker hooks - repo: https://github.com/IamTheFij/docker-pre-commit - rev: v2.1.0 + rev: v2.1.1 hooks: - id: docker-compose-check diff --git a/.yamllint b/.yamllint index 76a1cce..2a119a6 100644 --- a/.yamllint +++ b/.yamllint @@ -8,6 +8,16 @@ rules: # this behavior. comments-indentation: disable + # yamllint does not allow inline mappings that exceed the line length by + # default. There are many scenarios where the inline mapping may be a key, + # hash, or other long value that would exceed the line length but cannot + # reasonably be broken across lines. + line-length: + # This rule implies the allow-non-breakable-words rule + allow-non-breakable-inline-mappings: true + # Allows a 10% overage from the default limit of 80 + max: 88 + # yamllint doesn't like when we use yes and no for true and false, # but that's pretty standard in Ansible. truthy: disable diff --git a/README.md b/README.md index 07dc5db..b4780b1 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,17 @@ # log4j-md-yml # +<<<<<<< HEAD [![GitHub Build Status](https://github.com/cisagov/log4j-md-yml/workflows/build/badge.svg)](https://github.com/cisagov/log4j-md-yml/actions) [![Coverage Status](https://coveralls.io/repos/github/cisagov/log4j-md-yml/badge.svg?branch=develop)](https://coveralls.io/github/cisagov/log4j-md-yml?branch=develop) [![Total alerts](https://img.shields.io/lgtm/alerts/g/cisagov/log4j-md-yml.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/log4j-md-yml/alerts/) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/cisagov/log4j-md-yml.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/log4j-md-yml/context:python) [![Known Vulnerabilities](https://snyk.io/test/github/cisagov/log4j-md-yml/develop/badge.svg)](https://snyk.io/test/github/cisagov/log4j-md-yml) +======= +[![GitHub Build Status](https://github.com/cisagov/skeleton-python-library/workflows/build/badge.svg)](https://github.com/cisagov/skeleton-python-library/actions) +[![CodeQL](https://github.com/cisagov/skeleton-python-library/workflows/CodeQL/badge.svg)](https://github.com/cisagov/skeleton-python-library/actions/workflows/codeql-analysis.yml) +[![Coverage Status](https://coveralls.io/repos/github/cisagov/skeleton-python-library/badge.svg?branch=develop)](https://coveralls.io/github/cisagov/skeleton-python-library?branch=develop) +[![Known Vulnerabilities](https://snyk.io/test/github/cisagov/skeleton-python-library/develop/badge.svg)](https://snyk.io/test/github/cisagov/skeleton-python-library) +>>>>>>> 65604c7e134491f497f612f6eaebded8f411bec5 This repository contains Python code to: diff --git a/bump_version.sh b/bump_version.sh index 3154754..21f3aa0 100755 --- a/bump_version.sh +++ b/bump_version.sh @@ -11,6 +11,9 @@ VERSION_FILE=src/_log4j_md_yml_version.py HELP_INFORMATION="bump_version.sh (show|major|minor|patch|prerelease|build|finalize)" old_version=$(sed -n "s/^__version__ = \"\(.*\)\"$/\1/p" $VERSION_FILE) +# Comment out periods so they are interpreted as periods and don't +# just match any character +old_version_regex=${old_version//\./\\\.} if [ $# -ne 1 ]; then echo "$HELP_INFORMATION" @@ -22,7 +25,7 @@ else # A temp file is used to provide compatability with macOS development # as a result of macOS using the BSD version of sed tmp_file=/tmp/version.$$ - sed "s/$old_version/$new_version/" $VERSION_FILE > $tmp_file + sed "s/$old_version_regex/$new_version/" $VERSION_FILE > $tmp_file mv $tmp_file $VERSION_FILE git add $VERSION_FILE git commit -m"Bump version from $old_version to $new_version" @@ -34,10 +37,10 @@ else # A temp file is used to provide compatability with macOS development # as a result of macOS using the BSD version of sed tmp_file=/tmp/version.$$ - sed "s/$old_version/$new_version/" $VERSION_FILE > $tmp_file + sed "s/$old_version_regex/$new_version/" $VERSION_FILE > $tmp_file mv $tmp_file $VERSION_FILE git add $VERSION_FILE - git commit -m"Bump version from $old_version to $new_version" + git commit -m"Finalize version from $old_version to $new_version" git push ;; show) diff --git a/setup.py b/setup.py index 2ae89e7..2572c03 100644 --- a/setup.py +++ b/setup.py @@ -74,7 +74,17 @@ def get_version(version_file): # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. "Programming Language :: Python :: 3", +<<<<<<< HEAD +======= + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", +>>>>>>> 65604c7e134491f497f612f6eaebded8f411bec5 "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", ], python_requires=">=3.10", # What does your project relate to? diff --git a/src/_log4j_md_yml_version.py b/src/_log4j_md_yml_version.py index 9c44f4c..7f23aaf 100644 --- a/src/_log4j_md_yml_version.py +++ b/src/_log4j_md_yml_version.py @@ -1,2 +1,6 @@ """This file defines the version of this module.""" +<<<<<<< HEAD:src/_log4j_md_yml_version.py __version__ = "1.1.1" +======= +__version__ = "0.2.0" +>>>>>>> 65604c7e134491f497f612f6eaebded8f411bec5:src/example/_version.py