pull/113/head
commit
83c31e7d51
@ -0,0 +1,22 @@ |
||||
--- |
||||
# See https://ansible-lint.readthedocs.io/en/latest/configuring.html |
||||
# for a list of the configuration elements that can exist in this |
||||
# file. |
||||
enable_list: |
||||
# Useful checks that one must opt-into. See here for more details: |
||||
# https://ansible-lint.readthedocs.io/en/latest/rules.html |
||||
- fcqn-builtins |
||||
- no-log-password |
||||
- no-same-owner |
||||
exclude_paths: |
||||
# This exclusion is implicit, unless exclude_paths is defined |
||||
- .cache |
||||
# Seems wise to ignore this too |
||||
- .github |
||||
# ansible-lint doesn't like the role name in this playbook, but it's |
||||
# what molecule requires |
||||
- molecule/default/converge.yml |
||||
# These two are Molecule configuration files, not Ansible playbooks |
||||
- molecule/default/molecule-no-systemd.yml |
||||
- molecule/default/molecule-with-systemd.yml |
||||
use_default_rules: true |
@ -0,0 +1,13 @@ |
||||
--- |
||||
# Configuration file for the Bandit python security scanner |
||||
# https://bandit.readthedocs.io/en/latest/config.html |
||||
|
||||
# Tests are first included by `tests`, and then excluded by `skips`. |
||||
# If `tests` is empty, all tests are are considered included. |
||||
|
||||
tests: |
||||
# - B101 |
||||
# - B102 |
||||
|
||||
skips: |
||||
# - B101 # skip "assert used" check since assertions are required in pytests |
@ -0,0 +1,25 @@ |
||||
[flake8] |
||||
max-line-length = 80 |
||||
# Select (turn on) |
||||
# * Complexity violations reported by mccabe (C) - |
||||
# http://flake8.pycqa.org/en/latest/user/error-codes.html#error-violation-codes |
||||
# * Documentation conventions compliance reported by pydocstyle (D) - |
||||
# http://www.pydocstyle.org/en/stable/error_codes.html |
||||
# * Default errors and warnings reported by pycodestyle (E and W) - |
||||
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes |
||||
# * Default errors reported by pyflakes (F) - |
||||
# http://flake8.pycqa.org/en/latest/glossary.html#term-pyflakes |
||||
# * Default warnings reported by flake8-bugbear (B) - |
||||
# https://github.com/PyCQA/flake8-bugbear#list-of-warnings |
||||
# * The B950 flake8-bugbear opinionated warning - |
||||
# https://github.com/PyCQA/flake8-bugbear#opinionated-warnings |
||||
select = C,D,E,F,W,B,B950 |
||||
# Ignore flake8's default warning about maximum line length, which has |
||||
# a hard stop at the configured value. Instead we use |
||||
# flake8-bugbear's B950, which allows up to 10% overage. |
||||
# |
||||
# Also ignore flake8's warning about line breaks before binary |
||||
# operators. It no longer agrees with PEP8. See, for example, here: |
||||
# https://github.com/ambv/black/issues/21. Guido agrees here: |
||||
# https://github.com/python/peps/commit/c59c4376ad233a62ca4b3a6060c81368bd21e85b. |
||||
ignore = E501,W503 |
@ -0,0 +1,10 @@ |
||||
# Each line is a file pattern followed by one or more owners. |
||||
|
||||
# These owners will be the default owners for everything in the |
||||
# repo. Unless a later match takes precedence, these owners will be |
||||
# requested for review when someone opens a pull request. |
||||
* @dav3r @felddy @jsf9k @mcdonnnj |
||||
|
||||
# These folks own any files in the .github directory at the root of |
||||
# the repository and any of its subdirectories. |
||||
/.github/ @dav3r @felddy @jsf9k @mcdonnnj |
@ -0,0 +1,18 @@ |
||||
--- |
||||
|
||||
version: 2 |
||||
updates: |
||||
- package-ecosystem: "github-actions" |
||||
directory: "/" |
||||
schedule: |
||||
interval: "weekly" |
||||
|
||||
- package-ecosystem: "pip" |
||||
directory: "/" |
||||
schedule: |
||||
interval: "weekly" |
||||
|
||||
- package-ecosystem: "terraform" |
||||
directory: "/" |
||||
schedule: |
||||
interval: "weekly" |
@ -0,0 +1,104 @@ |
||||
--- |
||||
name: build |
||||
|
||||
on: |
||||
push: |
||||
pull_request: |
||||
repository_dispatch: |
||||
types: [apb] |
||||
|
||||
env: |
||||
CURL_CACHE_DIR: ~/.cache/curl |
||||
PIP_CACHE_DIR: ~/.cache/pip |
||||
PRE_COMMIT_CACHE_DIR: ~/.cache/pre-commit |
||||
RUN_TMATE: ${{ secrets.RUN_TMATE }} |
||||
|
||||
jobs: |
||||
lint: |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- id: setup-env |
||||
uses: cisagov/setup-env-github-action@develop |
||||
- uses: actions/checkout@v2 |
||||
- id: setup-python |
||||
uses: actions/setup-python@v2 |
||||
with: |
||||
python-version: 3.9 |
||||
# 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 |
||||
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/')" |
||||
- name: Lookup Go cache directory |
||||
id: go-cache |
||||
run: | |
||||
echo "::set-output name=dir::$(go env GOCACHE)" |
||||
- uses: actions/cache@v2 |
||||
env: |
||||
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\ |
||||
py${{ steps.setup-python.outputs.python-version }}-\ |
||||
go${{ steps.go-version.outputs.version }}-\ |
||||
packer${{ steps.setup-env.outputs.packer-version }}-\ |
||||
tf${{ steps.setup-env.outputs.terraform-version }}-" |
||||
with: |
||||
# Note that the .terraform directory IS NOT included in the |
||||
# cache because if we were caching, then we would need to use |
||||
# the `-upgrade=true` option. This option blindly pulls down the |
||||
# latest modules and providers instead of checking to see if an |
||||
# update is required. That behavior defeats the benefits of caching. |
||||
# so there is no point in doing it for the .terraform directory. |
||||
path: | |
||||
${{ env.PIP_CACHE_DIR }} |
||||
${{ env.PRE_COMMIT_CACHE_DIR }} |
||||
${{ env.CURL_CACHE_DIR }} |
||||
${{ steps.go-cache.outputs.dir }} |
||||
key: "${{ env.BASE_CACHE_KEY }}\ |
||||
${{ hashFiles('**/requirements-test.txt') }}-\ |
||||
${{ hashFiles('**/requirements.txt') }}-\ |
||||
${{ hashFiles('**/.pre-commit-config.yaml') }}" |
||||
restore-keys: | |
||||
${{ env.BASE_CACHE_KEY }} |
||||
- name: Setup curl cache |
||||
run: mkdir -p ${{ env.CURL_CACHE_DIR }} |
||||
- name: Install Packer |
||||
env: |
||||
PACKER_VERSION: ${{ steps.setup-env.outputs.packer-version }} |
||||
run: | |
||||
PACKER_ZIP="packer_${PACKER_VERSION}_linux_amd64.zip" |
||||
curl --output ${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}" \ |
||||
--time-cond ${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}" \ |
||||
--location \ |
||||
"https://releases.hashicorp.com/packer/${PACKER_VERSION}/${PACKER_ZIP}" |
||||
sudo unzip -d /opt/packer \ |
||||
${{ 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 |
||||
with: |
||||
terraform_version: ${{ steps.setup-env.outputs.terraform-version }} |
||||
- name: Install shfmt |
||||
env: |
||||
PACKAGE_URL: mvdan.cc/sh/v3/cmd/shfmt |
||||
PACKAGE_VERSION: ${{ steps.setup-env.outputs.shfmt-version }} |
||||
run: go install ${PACKAGE_URL}@${PACKAGE_VERSION} |
||||
- name: Install Terraform-docs |
||||
env: |
||||
PACKAGE_URL: github.com/terraform-docs/terraform-docs |
||||
PACKAGE_VERSION: ${{ steps.setup-env.outputs.terraform-docs-version }} |
||||
run: go install ${PACKAGE_URL}@${PACKAGE_VERSION} |
||||
- name: Install dependencies |
||||
run: | |
||||
python -m pip install --upgrade pip |
||||
pip install --upgrade --requirement requirements-test.txt |
||||
- name: Set up pre-commit hook environments |
||||
run: pre-commit install-hooks |
||||
- name: Run pre-commit on all files |
||||
run: pre-commit run --all-files |
||||
- name: Setup tmate debug session |
||||
uses: mxschmitt/action-tmate@v3 |
||||
if: env.RUN_TMATE |
@ -0,0 +1,8 @@ |
||||
# This file specifies intentionally untracked files that Git should ignore. |
||||
# Files already tracked by Git are not affected. |
||||
# See: https://git-scm.com/docs/gitignore |
||||
|
||||
## Python ## |
||||
__pycache__ |
||||
.mypy_cache |
||||
.python-version |
@ -0,0 +1,10 @@ |
||||
[settings] |
||||
combine_star=true |
||||
force_sort_within_sections=true |
||||
|
||||
import_heading_stdlib=Standard Python Libraries |
||||
import_heading_thirdparty=Third-Party Libraries |
||||
import_heading_firstparty=cisagov Libraries |
||||
|
||||
# Run isort under the black profile to align with our other Python linting |
||||
profile=black |
@ -0,0 +1,50 @@ |
||||
--- |
||||
|
||||
# Default state for all rules |
||||
default: true |
||||
|
||||
# MD003/heading-style/header-style - Heading style |
||||
MD003: |
||||
# Enforce the ATX-closed style of header |
||||
style: "atx_closed" |
||||
|
||||
# MD004/ul-style - Unordered list style |
||||
MD004: |
||||
# Enforce dashes for unordered lists |
||||
style: "dash" |
||||
|
||||
# MD013/line-length - Line length |
||||
MD013: |
||||
# Do not enforce for code blocks |
||||
code_blocks: false |
||||
# Do not enforce for tables |
||||
tables: false |
||||
|
||||
# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the |
||||
# same content |
||||
MD024: |
||||
# Allow headers with the same content as long as they are not in the same |
||||
# parent heading |
||||
allow_different_nesting: true |
||||
|
||||
# MD029/ol-prefix - Ordered list item prefix |
||||
MD029: |
||||
# Enforce the `1.` style for ordered lists |
||||
style: "one" |
||||
|
||||
# MD033/no-inline-html - Inline HTML |
||||
MD033: |
||||
# The h1 and img elements are allowed to permit header images |
||||
allowed_elements: |
||||
- h1 |
||||
- img |
||||
|
||||
# MD035/hr-style - Horizontal rule style |
||||
MD035: |
||||
# Enforce dashes for horizontal rules |
||||
style: "---" |
||||
|
||||
# MD046/code-block-style Code block style |
||||
MD046: |
||||
# Enforce the fenced style for code blocks |
||||
style: "fenced" |
@ -0,0 +1,131 @@ |
||||
--- |
||||
default_language_version: |
||||
# force all unspecified python hooks to run python3 |
||||
python: python3 |
||||
|
||||
repos: |
||||
- repo: https://github.com/pre-commit/pre-commit-hooks |
||||
rev: v4.0.1 |
||||
hooks: |
||||
- id: check-case-conflict |
||||
- id: check-executables-have-shebangs |
||||
- id: check-json |
||||
- id: check-merge-conflict |
||||
- id: check-toml |
||||
- id: check-xml |
||||
- id: debug-statements |
||||
- id: detect-aws-credentials |
||||
args: |
||||
- --allow-missing-credentials |
||||
- id: detect-private-key |
||||
- id: end-of-file-fixer |
||||
exclude: files/(issue|motd) |
||||
- id: mixed-line-ending |
||||
args: |
||||
- --fix=lf |
||||
- id: pretty-format-json |
||||
args: |
||||
- --autofix |
||||
- id: requirements-txt-fixer |
||||
- id: trailing-whitespace |
||||
|
||||
# Text file hooks |
||||
- repo: https://github.com/igorshubovych/markdownlint-cli |
||||
rev: v0.29.0 |
||||
hooks: |
||||
- id: markdownlint |
||||
args: |
||||
- --config=.mdl_config.yaml |
||||
- repo: https://github.com/pre-commit/mirrors-prettier |
||||
rev: v2.4.1 |
||||
hooks: |
||||
- id: prettier |
||||
- repo: https://github.com/adrienverge/yamllint |
||||
rev: v1.26.3 |
||||
hooks: |
||||
- id: yamllint |
||||
args: |
||||
- --strict |
||||
|
||||
# pre-commit hooks |
||||
- repo: https://github.com/pre-commit/pre-commit |
||||
rev: v2.15.0 |
||||
hooks: |
||||
- id: validate_manifest |
||||
|
||||
# Shell script hooks |
||||
- repo: https://github.com/cisagov/pre-commit-shfmt |
||||
rev: v0.0.2 |
||||
hooks: |
||||
- id: shfmt |
||||
args: |
||||
# Indent by two spaces |
||||
- -i |
||||
- '2' |
||||
# Binary operators may start a line |
||||
- -bn |
||||
# Switch cases are indented |
||||
- -ci |
||||
# Redirect operators are followed by a space |
||||
- -sr |
||||
- repo: https://github.com/detailyang/pre-commit-shell |
||||
rev: 1.0.5 |
||||
hooks: |
||||
- id: shell-lint |
||||
|
||||
# Python hooks |
||||
- repo: https://github.com/PyCQA/bandit |
||||
rev: 1.7.0 |
||||
hooks: |
||||
- id: bandit |
||||
args: |
||||
- --config=.bandit.yml |
||||
- repo: https://github.com/psf/black |
||||
rev: 21.9b0 |
||||
hooks: |
||||
- id: black |
||||
- repo: https://gitlab.com/pycqa/flake8 |
||||
rev: 3.9.2 |
||||
hooks: |
||||
- id: flake8 |
||||
additional_dependencies: |
||||
- flake8-docstrings |
||||
- repo: https://github.com/PyCQA/isort |
||||
rev: 5.9.3 |
||||
hooks: |
||||
- id: isort |
||||
- repo: https://github.com/pre-commit/mirrors-mypy |
||||
rev: v0.910-1 |
||||
hooks: |
||||
- id: mypy |
||||
- repo: https://github.com/asottile/pyupgrade |
||||
rev: v2.29.0 |
||||
hooks: |
||||
- id: pyupgrade |
||||
|
||||
# Ansible hooks |
||||
- repo: https://github.com/ansible-community/ansible-lint |
||||
rev: v5.2.1 |
||||
hooks: |
||||
- id: ansible-lint |
||||
# files: molecule/default/playbook.yml |
||||
|
||||
# Terraform hooks |
||||
- repo: https://github.com/antonbabenko/pre-commit-terraform |
||||
rev: v1.52.0 |
||||
hooks: |
||||
- id: terraform_fmt |
||||
- id: terraform_validate |
||||
|
||||
# Docker hooks |
||||
- repo: https://github.com/IamTheFij/docker-pre-commit |
||||
rev: v2.0.1 |
||||
hooks: |
||||
- id: docker-compose-check |
||||
|
||||
# Packer hooks |
||||
- repo: https://github.com/cisagov/pre-commit-packer |
||||
rev: v0.0.2 |
||||
hooks: |
||||
- id: packer_validate |
||||
- id: packer_fmt |
@ -0,0 +1,7 @@ |
||||
# Already being linted by pretty-format-json |
||||
*.json |
||||
# Already being linted by mdl |
||||
*.md |
||||
# Already being linted by yamllint |
||||
*.yaml |
||||
*.yml |
@ -0,0 +1,7 @@ |
||||
--- |
||||
extends: default |
||||
|
||||
rules: |
||||
# yamllint doesn't like when we use yes and no for true and false, |
||||
# but that's pretty standard in Ansible. |
||||
truthy: disable |
@ -0,0 +1,165 @@ |
||||
# Welcome # |
||||
|
||||
We're so glad you're thinking about contributing to this open source |
||||
project! If you're unsure or afraid of anything, just ask or submit |
||||
the issue or pull request anyway. The worst that can happen is that |
||||
you'll be politely asked to change something. We appreciate any sort |
||||
of contribution, and don't want a wall of rules to get in the way of |
||||
that. |
||||
|
||||
Before contributing, we encourage you to read our CONTRIBUTING policy |
||||
(you are here), our [LICENSE](LICENSE), and our [README](README.md), |
||||
all of which should be in this repository. |
||||
|
||||
## Issues ## |
||||
|
||||
If you want to report a bug or request a new feature, the most direct |
||||
method is to [create an |
||||
issue](https://github.com/cisagov/skeleton-generic/issues) in this |
||||
repository. We recommend that you first search through existing |
||||
issues (both open and closed) to check if your particular issue has |
||||
already been reported. If it has then you might want to add a comment |
||||
to the existing issue. If it hasn't then feel free to create a new |
||||
one. |
||||
|
||||
## Pull requests ## |
||||
|
||||
If you choose to [submit a pull |
||||
request](https://github.com/cisagov/skeleton-generic/pulls), you will |
||||
notice that our continuous integration (CI) system runs a fairly |
||||
extensive set of linters and syntax checkers. Your pull request may |
||||
fail these checks, and that's OK. If you want you can stop there and |
||||
wait for us to make the necessary corrections to ensure your code |
||||
passes the CI checks. |
||||
|
||||
If you want to make the changes yourself, or if you want to become a |
||||
regular contributor, then you will want to set up |
||||
[pre-commit](https://pre-commit.com/) on your local machine. Once you |
||||
do that, the CI checks will run locally before you even write your |
||||
commit message. This speeds up your development cycle considerably. |
||||
|
||||
### Setting up pre-commit ### |
||||
|
||||
There are a few ways to do this, but we prefer to use |
||||
[`pyenv`](https://github.com/pyenv/pyenv) and |
||||
[`pyenv-virtualenv`](https://github.com/pyenv/pyenv-virtualenv) to |
||||
create and manage a Python virtual environment specific to this |
||||
project. |
||||
|
||||
If you already have `pyenv` and `pyenv-virtualenv` configured you can |
||||
take advantage of the `setup-env` tool in this repo to automate the |
||||
entire environment configuration process. |
||||
|
||||
```console |
||||
./setup-env |
||||
``` |
||||
|
||||
Otherwise, follow the steps below to manually configure your |
||||
environment. |
||||
|
||||
#### Installing and using `pyenv` and `pyenv-virtualenv` #### |
||||
|
||||
On the Mac, we recommend installing [brew](https://brew.sh/). Then |
||||
installation is as simple as `brew install pyenv pyenv-virtualenv` and |
||||
adding this to your profile: |
||||
|
||||
```bash |
||||
export PYENV_ROOT="$HOME/.pyenv" |
||||
export PATH="$PYENV_ROOT/bin:$PATH" |
||||
eval "$(pyenv init --path)" |
||||
eval "$(pyenv init -)" |
||||
eval "$(pyenv virtualenv-init -)" |
||||
``` |
||||
|
||||
For Linux, Windows Subsystem for Linux (WSL), or on the Mac (if you |
||||
don't want to use `brew`) you can use |
||||
[pyenv/pyenv-installer](https://github.com/pyenv/pyenv-installer) to |
||||
install the necessary tools. Before running this ensure that you have |
||||
installed the prerequisites for your platform according to the |
||||
[`pyenv` wiki |
||||
page](https://github.com/pyenv/pyenv/wiki/common-build-problems). |
||||
|
||||
On WSL you should treat your platform as whatever Linux distribution |
||||
you've chosen to install. |
||||
|
||||
Once you have installed `pyenv` you will need to add the following |
||||
lines to your `.bash_profile` (or `.profile`): |
||||
|
||||
```bash |
||||
export PYENV_ROOT="$HOME/.pyenv" |
||||
export PATH="$PYENV_ROOT/bin:$PATH" |
||||
eval "$(pyenv init --path)" |
||||
``` |
||||
|
||||
and then add the following lines to your `.bashrc`: |
||||
|
||||
```bash |
||||
eval "$(pyenv init -)" |
||||
eval "$(pyenv virtualenv-init -)" |
||||
``` |
||||
|
||||
If you want more information about setting up `pyenv` once installed, please run |
||||
|
||||
```console |
||||
pyenv init |
||||
``` |
||||
|
||||
and |
||||
|
||||
```console |
||||
pyenv virtualenv-init |
||||
``` |
||||
|
||||
for the current configuration instructions. |
||||
|
||||
If you are using a shell other than `bash` you should follow the |
||||
instructions that the `pyenv-installer` script outputs. |
||||
|
||||
You will need to reload your shell for these changes to take effect so |
||||
you can begin to use `pyenv`. |
||||
|
||||
For a list of Python versions that are already installed and ready to |
||||
use with `pyenv`, use the command `pyenv versions`. To see a list of |
||||
the Python versions available to be installed and used with `pyenv` |
||||
use the command `pyenv install --list`. You can read more |
||||
[here](https://github.com/pyenv/pyenv/blob/master/COMMANDS.md) about |
||||
the many things that `pyenv` can do. See |
||||
[here](https://github.com/pyenv/pyenv-virtualenv#usage) for the |
||||
additional capabilities that pyenv-virtualenv adds to the `pyenv` |
||||
command. |
||||
|
||||
#### Creating the Python virtual environment #### |
||||
|
||||
Once `pyenv` and `pyenv-virtualenv` are installed on your system, you |
||||
can create and configure the Python virtual environment with these |
||||
commands: |
||||
|
||||
```console |
||||
cd skeleton-generic |
||||
pyenv virtualenv <python_version_to_use> skeleton-generic |
||||
pyenv local skeleton-generic |
||||
pip install --requirement requirements-dev.txt |
||||
``` |
||||
|
||||
#### Installing the pre-commit hook #### |
||||
|
||||
Now setting up pre-commit is as simple as: |
||||
|
||||
```console |
||||
pre-commit install |
||||
``` |
||||
|
||||
At this point the pre-commit checks will run against any files that |
||||
you attempt to commit. If you want to run the checks against the |
||||
entire repo, just execute `pre-commit run --all-files`. |
||||
|
||||
## Public domain ## |
||||
|
||||
This project is in the public domain within the United States, and |
||||
copyright and related rights in the work worldwide are waived through |
||||
the [CC0 1.0 Universal public domain |
||||
dedication](https://creativecommons.org/publicdomain/zero/1.0/). |
||||
|
||||
All contributions to this project will be released under the CC0 |
||||
dedication. By submitting a pull request, you are agreeing to comply |
||||
with this waiver of copyright interest. |
@ -0,0 +1,116 @@ |
||||
CC0 1.0 Universal |
||||
|
||||
Statement of Purpose |
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer |
||||
exclusive Copyright and Related Rights (defined below) upon the creator and |
||||
subsequent owner(s) (each and all, an "owner") of an original work of |
||||
authorship and/or a database (each, a "Work"). |
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for the |
||||
purpose of contributing to a commons of creative, cultural and scientific |
||||
works ("Commons") that the public can reliably and without fear of later |
||||
claims of infringement build upon, modify, incorporate in other works, reuse |
||||
and redistribute as freely as possible in any form whatsoever and for any |
||||
purposes, including without limitation commercial purposes. These owners may |
||||
contribute to the Commons to promote the ideal of a free culture and the |
||||
further production of creative, cultural and scientific works, or to gain |
||||
reputation or greater distribution for their Work in part through the use and |
||||
efforts of others. |
||||
|
||||
For these and/or other purposes and motivations, and without any expectation |
||||
of additional consideration or compensation, the person associating CC0 with a |
||||
Work (the "Affirmer"), to the extent that he or she is an owner of Copyright |
||||
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work |
||||
and publicly distribute the Work under its terms, with knowledge of his or her |
||||
Copyright and Related Rights in the Work and the meaning and intended legal |
||||
effect of CC0 on those rights. |
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be |
||||
protected by copyright and related or neighboring rights ("Copyright and |
||||
Related Rights"). Copyright and Related Rights include, but are not limited |
||||
to, the following: |
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display, communicate, |
||||
and translate a Work; |
||||
|
||||
ii. moral rights retained by the original author(s) and/or performer(s); |
||||
|
||||
iii. publicity and privacy rights pertaining to a person's image or likeness |
||||
depicted in a Work; |
||||
|
||||
iv. rights protecting against unfair competition in regards to a Work, |
||||
subject to the limitations in paragraph 4(a), below; |
||||
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data in |
||||
a Work; |
||||
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the |
||||
European Parliament and of the Council of 11 March 1996 on the legal |
||||
protection of databases, and under any national implementation thereof, |
||||
including any amended or successor version of such directive); and |
||||
|
||||
vii. other similar, equivalent or corresponding rights throughout the world |
||||
based on applicable law or treaty, and any national implementations thereof. |
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention of, |
||||
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and |
||||
unconditionally waives, abandons, and surrenders all of Affirmer's Copyright |
||||
and Related Rights and associated claims and causes of action, whether now |
||||
known or unknown (including existing as well as future claims and causes of |
||||
action), in the Work (i) in all territories worldwide, (ii) for the maximum |
||||
duration provided by applicable law or treaty (including future time |
||||
extensions), (iii) in any current or future medium and for any number of |
||||
copies, and (iv) for any purpose whatsoever, including without limitation |
||||
commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes |
||||
the Waiver for the benefit of each member of the public at large and to the |
||||
detriment of Affirmer's heirs and successors, fully intending that such Waiver |
||||
shall not be subject to revocation, rescission, cancellation, termination, or |
||||
any other legal or equitable action to disrupt the quiet enjoyment of the Work |
||||
by the public as contemplated by Affirmer's express Statement of Purpose. |
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason be |
||||
judged legally invalid or ineffective under applicable law, then the Waiver |
||||
shall be preserved to the maximum extent permitted taking into account |
||||
Affirmer's express Statement of Purpose. In addition, to the extent the Waiver |
||||
is so judged Affirmer hereby grants to each affected person a royalty-free, |
||||
non transferable, non sublicensable, non exclusive, irrevocable and |
||||
unconditional license to exercise Affirmer's Copyright and Related Rights in |
||||
the Work (i) in all territories worldwide, (ii) for the maximum duration |
||||
provided by applicable law or treaty (including future time extensions), (iii) |
||||
in any current or future medium and for any number of copies, and (iv) for any |
||||
purpose whatsoever, including without limitation commercial, advertising or |
||||
promotional purposes (the "License"). The License shall be deemed effective as |
||||
of the date CC0 was applied by Affirmer to the Work. Should any part of the |
||||
License for any reason be judged legally invalid or ineffective under |
||||
applicable law, such partial invalidity or ineffectiveness shall not |
||||
invalidate the remainder of the License, and in such case Affirmer hereby |
||||
affirms that he or she will not (i) exercise any of his or her remaining |
||||
Copyright and Related Rights in the Work or (ii) assert any associated claims |
||||
and causes of action with respect to the Work, in either case contrary to |
||||
Affirmer's express Statement of Purpose. |
||||
|
||||
4. Limitations and Disclaimers. |
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned, |
||||
surrendered, licensed or otherwise affected by this document. |
||||
|
||||
b. Affirmer offers the Work as-is and makes no representations or warranties |
||||
of any kind concerning the Work, express, implied, statutory or otherwise, |
||||
including without limitation warranties of title, merchantability, fitness |
||||
for a particular purpose, non infringement, or the absence of latent or |
||||
other defects, accuracy, or the present or absence of errors, whether or not |
||||
discoverable, all to the greatest extent permissible under applicable law. |
||||
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons |
||||
that may apply to the Work or any use thereof, including without limitation |
||||
any person's Copyright and Related Rights in the Work. Further, Affirmer |
||||
disclaims responsibility for obtaining any necessary consents, permissions |
||||
or other rights required for any use of the Work. |
||||
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a |
||||
party to this document and has no duty or obligation with respect to this |
||||
CC0 or use of the Work. |
||||
|
||||
For more information, please see |
||||
<http://creativecommons.org/publicdomain/zero/1.0/> |
@ -0,0 +1,2 @@ |
||||
--requirement requirements-test.txt |
||||
ipython |
@ -0,0 +1,2 @@ |
||||
--requirement requirements.txt |
||||
pre-commit |
@ -0,0 +1,2 @@ |
||||
setuptools |
||||
wheel |
@ -0,0 +1,190 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
set -o nounset |
||||
set -o errexit |
||||
set -o pipefail |
||||
|
||||
USAGE=$( |
||||
cat << 'END_OF_LINE' |
||||
Configure a development environment for this repository. |
||||
|
||||
It does the following: |
||||
- Verifies pyenv and pyenv-virtualenv are installed. |
||||
- Creates a Python virtual environment. |
||||
- Configures the activation of the virtual enviroment for the repo directory. |
||||
- Installs the requirements needed for development. |
||||
- Installs git pre-commit hooks. |
||||
- Configures git upstream remote "lineage" repositories. |
||||
|
||||
Usage: |
||||
setup-env [options] [virt_env_name] |
||||
setup-env (-h | --help) |
||||
|
||||
Options: |
||||
-f --force Delete virtual enviroment if it already exists. |
||||
-h --help Show this message. |
||||
-i --install-hooks Install hook environments for all environments in the |
||||
pre-commit config file. |
||||
|
||||
END_OF_LINE |
||||
) |
||||
|
||||
# Flag to force deletion and creation of virtual environment |
||||
FORCE=0 |
||||
|
||||
# Positional parameters |
||||
PARAMS="" |
||||
|
||||
# Parse command line arguments |
||||
while (("$#")); do |
||||
case "$1" in |
||||
-f | --force) |
||||
FORCE=1 |
||||
shift |
||||
;; |
||||
-h | --help) |
||||
echo "${USAGE}" |
||||
exit 0 |
||||
;; |
||||
-i | --install-hooks) |
||||
INSTALL_HOOKS=1 |
||||
shift |
||||
;; |
||||
-*) # unsupported flags |
||||
echo "Error: Unsupported flag $1" >&2 |
||||
exit 1 |
||||
;; |
||||
*) # preserve positional arguments |
||||
PARAMS="$PARAMS $1" |
||||
shift |
||||
;; |
||||
esac |
||||
done |
||||
|
||||
# set positional arguments in their proper place |
||||
eval set -- "$PARAMS" |
||||
|
||||
# Check to see if pyenv is installed |
||||
if [ -z "$(command -v pyenv)" ] || [ -z "$(command -v pyenv-virtualenv)" ]; then |
||||
echo "pyenv and pyenv-virtualenv are required." |
||||
if [[ "$OSTYPE" == "darwin"* ]]; then |
||||
cat << 'END_OF_LINE' |
||||
|
||||
On the Mac, we recommend installing brew, https://brew.sh/. Then installation |
||||
is as simple as `brew install pyenv pyenv-virtualenv` and adding this to your |
||||
profile: |
||||
|
||||
eval "$(pyenv init -)" |
||||
eval "$(pyenv virtualenv-init -)" |
||||
|
||||
END_OF_LINE |
||||
|
||||
fi |
||||
cat << 'END_OF_LINE' |
||||
For Linux, Windows Subsystem for Linux (WSL), or on the Mac (if you don't want |
||||
to use "brew") you can use https://github.com/pyenv/pyenv-installer to install |
||||
the necessary tools. Before running this ensure that you have installed the |
||||
prerequisites for your platform according to the pyenv wiki page, |
||||
https://github.com/pyenv/pyenv/wiki/common-build-problems. |
||||
|
||||
On WSL you should treat your platform as whatever Linux distribution you've |
||||
chosen to install. |
||||
|
||||
Once you have installed "pyenv" you will need to add the following lines to |
||||
your ".bashrc": |
||||
|
||||
export PATH="$PATH:$HOME/.pyenv/bin" |
||||
eval "$(pyenv init -)" |
||||
eval "$(pyenv virtualenv-init -)" |
||||
END_OF_LINE |
||||
exit 1 |
||||
fi |
||||
|
||||
set +o nounset |
||||
# Determine the virtual environment name |
||||
if [ "$1" ]; then |
||||
# Use the user-provided environment name |
||||
env_name=$1 |
||||
else |
||||
# Set the environment name to the last part of the working directory. |
||||
env_name=${PWD##*/} |
||||
fi |
||||
set -o nounset |
||||
|
||||
# Remove any lingering local configuration. |
||||
if [ $FORCE -ne 0 ]; then |
||||
rm -f .python-version |
||||
pyenv virtualenv-delete --force "${env_name}" || true |
||||
elif [[ -f .python-version ]]; then |
||||
cat << 'END_OF_LINE' |
||||
An existing .python-version file was found. Either remove this file yourself |
||||
or re-run with --force option to have it deleted along with the associated |
||||
virtual environment. |
||||
|
||||
rm .python-version |
||||
|
||||
END_OF_LINE |
||||
exit 1 |
||||
fi |
||||
|
||||
# Create a new virtual environment for this project |
||||
if ! pyenv virtualenv "${env_name}"; then |
||||
cat << END_OF_LINE |
||||
An existing virtual environment named $env_name was found. Either delete this |
||||
environment yourself or re-run with --force option to have it deleted. |
||||
|
||||
pyenv virtualenv-delete ${env_name} |
||||
|
||||
END_OF_LINE |
||||
exit 1 |
||||
fi |
||||
|
||||
# Set the local application-specific Python version(s) by writing the |
||||
# version name to a file named `.python-version'. |
||||
pyenv local "${env_name}" |
||||
|
||||
# Upgrade pip and friends |
||||
python3 -m pip install --upgrade pip setuptools wheel |
||||
|
||||
# Find a requirements file (if possible) and install |
||||
for req_file in "requirements-dev.txt" "requirements-test.txt" "requirements.txt"; do |
||||
if [[ -f $req_file ]]; then |
||||
pip install --requirement $req_file |
||||
break |
||||
fi |
||||
done |
||||
|
||||
# Install git pre-commit hooks now or later. |
||||
pre-commit install ${INSTALL_HOOKS:+"--install-hooks"} |
||||
|
||||
# Setup git remotes from lineage configuration |
||||
# This could fail if the remotes are already setup, but that is ok. |
||||
set +o errexit |
||||
|
||||
eval "$( |
||||
python3 << 'END_OF_LINE' |
||||
from pathlib import Path |
||||
import yaml |
||||
import sys |
||||
|
||||
LINEAGE_CONFIG = Path(".github/lineage.yml") |
||||
|
||||
if not LINEAGE_CONFIG.exists(): |
||||
print("No lineage configuration found.", file=sys.stderr) |
||||
sys.exit(0) |
||||
|
||||
with LINEAGE_CONFIG.open("r") as f: |
||||
lineage = yaml.safe_load(stream=f) |
||||
|
||||
if lineage["version"] == "1": |
||||
for parent_name, v in lineage["lineage"].items(): |
||||
remote_url = v["remote-url"] |
||||
print(f"git remote add {parent_name} {remote_url};") |
||||
print(f"git remote set-url --push {parent_name} no_push;") |
||||
else: |
||||
print(f'Unsupported lineage version: {lineage["version"]}', file=sys.stderr) |
||||
END_OF_LINE |
||||
)" |
||||
|
||||
# Qapla |
||||
echo "Success!" |
Loading…
Reference in new issue