Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtmckee committed Oct 26, 2023
0 parents commit 5466f19
Show file tree
Hide file tree
Showing 19 changed files with 891 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[{*.yaml,*.yml}]
indent_size = 2
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
github-actions:
patterns:
- "*"
76 changes: 76 additions & 0 deletions .github/workflows/readme_example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This workflow exists for several purposes:
#
# * Ensure that the example in the README is functional.
# * Ensure that the desired YAML formatting is enforced.
# * Ensure that the example action versions are maintained.
#
# Update PRs submitted by Dependabot should trigger pre-commit.ci,
# which will synchronize changes to this file into the README.
#

name: "📘 README example"

on:
pull_request:
push:
branches:
- "main"
- "releases"
schedule:
- cron: "27 19 * * *"

jobs:
readme_example:
strategy:
matrix:
run:
- os:
id: "ubuntu-latest"
name: "Linux"
- os:
id: "macos-latest"
name: "macOS"
- os:
id: "windows-latest"
name: "Windows"

name: "Test ${{ matrix.run.os.name }}"
runs-on: "${{ matrix.run.os.id }}"
steps:
# START_README_EXAMPLE_BLOCK
- uses: "actions/setup-python@v4"
with:
python-version: |
pypy3.10
3.11
- uses: "kurtmckee/detect-pythons@main"

- uses: "actions/cache@v3"
id: "restore-cache"
with:
# You may need to augment the list of files to hash.
# For example, you might add 'requirements/*.txt' or 'pyproject.toml'.
key: "${{ hashFiles('.python-identifiers') }}"
path: |
.tox/
.venv/
- name: "Identify .venv path"
shell: "bash"
run: "echo 'venv-path=${{ runner.os == 'Windows' && '.venv/Scripts' || '.venv/bin' }}' >> $GITHUB_ENV"

- name: "Create a virtual environment"
if: "steps.restore-cache.outputs.cache-hit == false"
run: |
python -m venv .venv
${{ env.venv-path }}/python -m pip install --upgrade pip setuptools wheel
# You may need to customize what gets installed next.
# However, tox is able to run test suites against multiple Pythons,
# so it's a helpful tool for efficient testing.
${{ env.venv-path }}/pip install tox
- name: "Run the test suite against all installed Pythons"
run: "${{ env.venv-path }}/tox"
# END_README_EXAMPLE_BLOCK
34 changes: 34 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Test"

on:
push:
branches:
- "main"

jobs:
test-linux:
name: "Test on ${{ matrix.config.os-name }}"
runs-on: "${{ matrix.config.runner }}"
strategy:
matrix:
config:
- os-name: "Linux"
runner: "ubuntu-latest"
test-label: "ci-test-linux"
- os-name: "macOS"
runner: "macos-latest"
test-label: "ci-test-macos"
- os-name: "Windows"
runner: "windows-latest"
test-label: "ci-test-windows"
fail-fast: false

steps:
- name: "Use it!"
id: "detector"
uses: "kurtmckee/detect-pythons@main"

- name: "Print it!"
shell: "bash"
run: |
echo '${{ steps.detector.outputs.python-identifiers }}'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
76 changes: 76 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
ci:
autoupdate_schedule: "monthly"

repos:
- repo: "meta"
hooks:
- id: "check-hooks-apply"
- id: "check-useless-excludes"

- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: "v4.5.0"
hooks:
- id: "trailing-whitespace"
- id: "end-of-file-fixer"
- id: "check-yaml"
- id: "check-added-large-files"

- repo: "https://github.com/psf/black-pre-commit-mirror"
rev: "23.9.1"
hooks:
- id: "black"
language_version: "python3.8"

- repo: "https://github.com/pycqa/isort"
rev: "5.12.0"
hooks:
- id: "isort"

- repo: "https://github.com/pycqa/flake8"
rev: "6.1.0"
hooks:
- id: "flake8"

- repo: "https://github.com/editorconfig-checker/editorconfig-checker.python"
rev: "2.7.3"
hooks:
- id: "editorconfig-checker"
# The README contains YAML syntax that is indented with 2 spaces.
# The .editorconfig file will continue to require 4 spaces,
# and this pre-commit hook will ignore the README.
exclude: "README.rst"

- repo: "local"
hooks:
- id: "sync-identify-code"
name: "Synchronize identify.py source code into 'detector.sh'"
language: "python"
entry: "python src/detect_pythons/sync_identify_code.py"
files: "^src/detect_pythons/identify.py$"

- repo: "https://github.com/shellcheck-py/shellcheck-py"
rev: "v0.9.0.6"
hooks:
- id: "shellcheck"
args:
- "--shell=bash"

- repo: "local"
hooks:
- id: "sync-detector-code"
name: "Synchronize detector source code into 'action.yml'"
language: "python"
entry: "python src/detect_pythons/sync_detector_code.py"
files: "^src/detect_pythons/detector.*$"
- id: "sync-readme-example"
name: "Synchronize a functional example into the README"
language: "python"
entry: "python src/detect_pythons/sync_readme_example.py"
always_run: true
pass_filenames: false

- repo: "https://github.com/python-jsonschema/check-jsonschema"
rev: "0.27.0"
hooks:
- id: "check-github-workflows"
- id: "check-dependabot"
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright 2023 Kurt McKee <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 5466f19

Please sign in to comment.