Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5327516
Backported changes to CONTRIBUTING.md from the development guide.
mcdonnnj Feb 10, 2020
3f6d654
Merge pull request #31 from cisagov/improvements/add_wsl_instructions
mcdonnnj Feb 10, 2020
f7a4166
Update Python version used to 3.8
mcdonnnj Feb 11, 2020
8116a89
Merge pull request #32 from cisagov/improvements/update_python_versio…
mcdonnnj Feb 11, 2020
b857939
Run pre-commit autoupdate.
mcdonnnj Feb 12, 2020
d99fd00
Flip cache order to mirror how it is done downstream.
mcdonnnj Feb 12, 2020
16872bf
Merge pull request #33 from cisagov/improvement/update_pre-commit_hooks
mcdonnnj Feb 12, 2020
e96577b
All references to '-r' for pip calls have been replaced with the more…
mcdonnnj Feb 18, 2020
a17986b
Merge pull request #34 from cisagov/improvements/use_verbose_pip_swit…
mcdonnnj Feb 19, 2020
067ee08
Autoupdate pre-commit hooks. Add mypy.
felddy Feb 20, 2020
6369cc6
Merge pull request #35 from cisagov/improvement/static_type_checking
felddy Feb 21, 2020
cb7b74e
Add script to create GitHub Actions secrets.
felddy Feb 21, 2020
be6e9c3
Merge branch 'develop' of github.com:cisagov/skeleton-generic into im…
felddy Feb 21, 2020
c9c5731
Correct isort config after seed-hook borked it.
felddy Feb 22, 2020
871a1a2
Add detection of GitHub repo name and extra users.
felddy Feb 22, 2020
ed1c4cc
Clarify tool documentation.
felddy Feb 22, 2020
4de5ee6
Replace travis docs with GitHub actions docs.
felddy Feb 22, 2020
c2e9711
Qapla'!
felddy Feb 22, 2020
bc8dfe5
Add link to secrets docs.
felddy Feb 22, 2020
bac7c9d
Clarify invocation of tool with bogus PAT.
felddy Feb 23, 2020
18cda94
Qapla'!
felddy Feb 23, 2020
ff55608
Add support for https GitHub clones.
felddy Feb 24, 2020
381953d
Normalize capitalization of "Terraform" app and ".terraform" dir
felddy Feb 24, 2020
3a6a031
Fix grammar and make reference to .terraform being a directory.
felddy Feb 24, 2020
c255822
Fix misspelled word.
felddy Feb 24, 2020
2acefd0
Raise exception if detection of repo name fails.
felddy Feb 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Cache pre-commit hooks
uses: actions/cache@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
path: ~/.cache/pre-commit
key: "${{ runner.os }}-pre-commit-\
${{ hashFiles('**/.pre-commit-config.yaml') }}"

python-version: 3.8
- name: Cache pip test requirements
uses: actions/cache@v1
with:
Expand All @@ -33,11 +23,15 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-test-
${{ runner.os }}-pip-

- name: Cache pre-commit hooks
uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: "${{ runner.os }}-pre-commit-\
${{ hashFiles('**/.pre-commit-config.yaml') }}"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade -r requirements-test.txt

pip install --upgrade --requirement requirements-test.txt
- name: Run pre-commit on all files
run: pre-commit run --all-files
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
__pycache__
.python-version
.coverage
.mypy_cache
.pytest_cache
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import_heading_thirdparty=Third-Party Libraries
import_heading_firstparty=cisagov Libraries

# Should be auto-populated by seed-isort-config hook
known_third_party=docopt,github
known_third_party=docopt,github,nacl,requests,setuptools,schema
# These must be manually set to correctly separate them from third party libraries
known_first_party=
26 changes: 15 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
rev: v2.5.0
hooks:
- id: check-executables-have-shebangs
- id: check-json
Expand All @@ -27,13 +27,13 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.19.0
rev: v0.22.0
hooks:
- id: markdownlint
args:
- --config=.mdl_config.json
- repo: https://github.com/adrienverge/yamllint
rev: v1.18.0
rev: v1.20.0
hooks:
- id: yamllint
- repo: https://github.com/detailyang/pre-commit-shell
Expand All @@ -47,7 +47,7 @@ repos:
additional_dependencies:
- flake8-docstrings
- repo: https://github.com/asottile/pyupgrade
rev: v1.25.1
rev: v2.0.0
hooks:
- id: pyupgrade
- repo: https://github.com/PyCQA/bandit
Expand All @@ -62,31 +62,35 @@ repos:
- id: black
# Disabling seed-isort-config since it doesn't identifying docopt, et al.
# as third-party libraries.
# - repo: https://github.com/asottile/seed-isort-config
# rev: v1.9.3
# hooks:
# - id: seed-isort-config
#- repo: https://github.com/asottile/seed-isort-config
# rev: v1.9.4
# hooks:
# - id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
# pick the isort version you'd like to use from
# https://github.com/pre-commit/mirrors-isort/releases
rev: v4.3.21
hooks:
- id: isort
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.1.1a5
rev: v4.2.0
hooks:
- id: ansible-lint
# files: molecule/default/playbook.yml
# files: molecule/default/playbook.yml
- repo: https://github.com/antonbabenko/pre-commit-terraform.git
rev: v1.12.0
hooks:
- id: terraform_fmt
- id: terraform_validate_no_variables
- repo: https://github.com/IamTheFij/docker-pre-commit
rev: v1.0.0
rev: v1.0.1
hooks:
- id: docker-compose-check
- repo: https://github.com/prettier/prettier
rev: 1.19.1
hooks:
- id: prettier
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.761
hooks:
- id: mypy
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ commands:
cd development-guide
pyenv virtualenv <python_version_to_use> development-guide
pyenv local development-guide
pip install -r requirements-dev.txt
pip install --requirement requirements-dev.txt
```

#### Installing the pre-commit hook ####
Expand Down
58 changes: 22 additions & 36 deletions project_setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,50 +110,36 @@ usage of the tool is:
This file will now contain definitions for all the Ansible roles. Edit
the file, and remove any role that will not be required for your project.

## Terraform IAM Credentials to Travis Tool πŸ”‘β€πŸ‘‰πŸ‘·πŸ» ##
## Terraform IAM Credentials to GitHub Secrets πŸ”‘β€πŸ‘‰πŸ€« ##

When Travis-CI needs credentials to run we provide them in its `.travis.yml`
file in an encrypted format. Extracting fresh IAM credentials from a
Terraform run,
[encrypting them properly](https://docs.travis-ci.com/user/environment-variables/#defining-encrypted-variables-in-travisyml)
, and then formatting them into well-formed `yml` that will make the linters
happy is no small task.
When GitHub Actions workflows require credentials to run we provide them via
[secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets).
This usually involves extracting the secrets from the Terraform state
json output. Then some pointing, clicking, cutting and pasting on the
repository's settings.

To simplify this task use the [`iam-to-travis`](scripts/iam-to-travis) tool
located in the [`scripts`](scripts) directory. The tool will output `yml`
that can be pasted directly into a `.travis.yml` file. The tool has
adjustable indentation and width with reasonable defaults.
To simplify this task use the [`iam-to-github`](scripts/iam-to-github) tool
located in the [`scripts`](scripts) directory. The tool will create secrets
using your
[personal access token (PAT)](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line).
Note: Your PAT needs to have the "repo" scope set.

Execute the tool from your GitHub project's terraform directory:

```bash
iam-to-travis
iam-to-github 9f4ae878de917c7cf191b9861d3c1cf9224939f7
```

```yml
# AWS_ACCESS_KEY_ID
- secure: "UZVXTpslA2qID+51nIlVOPaDZNdIuTuEw7AMG7045zEAuxtmViHBKL5z6fpwUnmV\
vqnjZksQGLuLnYFIX+E85ObwrFBj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K6rEtms6c3dwtHrssoHOsozADxVeK/I2two1QzcVsw92hRfF9ecWyV+QUaJ6iZYEk2VqgsDi\
NuBbVa2SQT9mO3A4fcn23fRjHy/ac/Cmz9q3hGKnMWl27CSRaPq7PR4sNPr9ebabRRrjAZ0I2\
UaWaDqIOwz85EWTQ6Y/53dgr2Zgv8KpfzfdNWhKtKS4woJGYPoU1k17V2TGZhs2S85XfT2aB3\
injrwJ5qqmcUljFdByuA08WyX4UkBCWtkJE="
```console
2020-02-22 15:50:36,059 INFO Using GitHub repository name: cisagov/ansible-role-dev-ssh-access
2020-02-22 15:50:36,060 INFO Searching Terraform state for IAM credentials.
2020-02-22 15:50:40,643 INFO Found credentials for user: test-ansible-role-dev-ssh-access
2020-02-22 15:50:40,643 INFO Creating GitHub API session using personal access token.
2020-02-22 15:50:40,644 INFO Requesting public key for repository cisagov/ansible-role-dev-ssh-access
2020-02-22 15:50:40,832 INFO Setting secrets for user: test-ansible-role-dev-ssh-access
2020-02-22 15:50:40,832 INFO Creating secret AWS_ACCESS_KEY_ID
2020-02-22 15:50:41,027 INFO Creating secret AWS_SECRET_ACCESS_KEY
2020-02-22 15:50:41,036 INFO Success!
```

## Managing SSM Parameters from Files πŸ—‚πŸ‘‰β˜οΈ ##
Expand Down
Loading