Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement GitHub Actions / Fix admin user existing #20

Merged
merged 57 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
78a230d
Add updates from running pre-commit autoupdate
dav3r Oct 18, 2019
b189690
Merge pull request #18 from cisagov/improvement/updates_from_precommi…
dav3r Oct 18, 2019
05a136b
Replace Travis-CI with GitHub actions.
felddy Oct 18, 2019
02fb008
Fix action shield link
felddy Oct 18, 2019
b31ad85
Disable ansible-lint until they fix their setup.py
felddy Oct 18, 2019
b11e39a
Remove extra line.
felddy Oct 18, 2019
12b91c4
Merge pull request #20 from cisagov/improvement/actions
felddy Oct 18, 2019
2d00271
Merge branch 'develop' of github.com:cisagov/skeleton-generic into im…
felddy Oct 18, 2019
41a17da
Convert travis config to workflow
felddy Oct 18, 2019
f2fb4db
Add continuation characters
felddy Oct 18, 2019
06a6967
Fix env var evaluations.
felddy Oct 18, 2019
36e84e8
Fix env variable calculation.
felddy Oct 18, 2019
36d2032
Rename the iam user module.
felddy Oct 18, 2019
1010680
Add more environment variables
felddy Oct 18, 2019
f94d582
Remove line that was driving Shane cray-cray.
felddy Oct 18, 2019
250bcb1
Add release event types to trigger
felddy Oct 18, 2019
d7c5baf
Bump terraform version
felddy Oct 18, 2019
8a7339b
Break patcher into published and unpublished modes
felddy Oct 18, 2019
55ec7b9
Remove github python library.
felddy Oct 18, 2019
8c06fdc
Replace Travis job URL with GitHub commit SHA.
felddy Oct 18, 2019
170349b
Replace express double-quotes with signel-quotes.
felddy Oct 18, 2019
6e1ec70
Work towards getting release tags out of GITHUB_REF
felddy Oct 18, 2019
2931243
Simplify patching of packer config.
felddy Oct 21, 2019
567f171
Simplify patching of packer config.
felddy Oct 21, 2019
d67acd4
Change environment variable name
felddy Oct 21, 2019
17e93fc
Remove boto3 requirement, and move semver.
felddy Oct 21, 2019
30f57f0
Split monolithic job into two workflows.
felddy Oct 21, 2019
c236191
Remove packer install from linter job
felddy Oct 21, 2019
5cbce59
Checkout the code we need to test.
felddy Oct 21, 2019
db82028
Bump version.
felddy Oct 21, 2019
d13017d
Add missing run command.
felddy Oct 21, 2019
87e3a78
Fix pre-release logic
felddy Oct 21, 2019
b37fe3a
Add boto3 to requirements.
felddy Oct 21, 2019
478df79
Add missing AWS variable.
felddy Oct 21, 2019
66de200
Change input from environment variable to stdin.
felddy Oct 24, 2019
d764e2a
Remove travis configuration.
felddy Oct 24, 2019
7d434d6
Split unified release workflow into separate files.
felddy Oct 24, 2019
1f3c6c1
Move environment variables from the job to the workflow.
felddy Oct 24, 2019
5e34fd8
Remove unused environment variable.
felddy Oct 24, 2019
b09c062
Update documentation to reflect changes to release workflows.
felddy Oct 24, 2019
22af38c
Re-enable ansible-lint.
felddy Oct 24, 2019
e843150
Auto-update pre-commit hooks.
felddy Oct 24, 2019
7ee9309
Change ansible-lint hook to point and fixed (unreleased) version.
felddy Oct 24, 2019
d339022
Change job name to match workflow.
felddy Oct 24, 2019
acc7681
Fix wrong environment variable name.
felddy Oct 24, 2019
882e81e
Remove build account, and sudo access at end of build.
felddy Oct 24, 2019
76f04ef
Attempt to at least clear the ssh authorized keys.
felddy Oct 24, 2019
15c30c0
Expand command flags for clarity.
felddy Oct 24, 2019
fb92c21
Remove shell provisioner.
felddy Oct 24, 2019
b2643e5
Change builder username so it more obvious on the server.
felddy Oct 24, 2019
cbeff8b
User name must be admin.
felddy Oct 24, 2019
fc68cf1
Re-add the shell provisioner with new cloud-init cleanup of default-user
felddy Oct 24, 2019
6a01198
Add command to disable default user creation.
felddy Oct 24, 2019
c5df4ed
Replace last reference to Travis-CI.
felddy Oct 24, 2019
190aa09
Sort workflow environment variables.
felddy Oct 24, 2019
f2fd977
Use new github action to set our tool versions via env.
felddy Oct 25, 2019
cb50101
Some small punctuation changes to help readability.
mcdonnnj Oct 25, 2019
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
53 changes: 53 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: build

on:
push:

env:
CURL_CACHE_DIR: $HOME/.cache/curl

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Setup cache # GitHub support coming soon
run: mkdir -p $CURL_CACHE_DIR
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade -r requirements-test.txt
- name: Run linters on all files
run: pre-commit run --all-files

test:
runs-on: ubuntu-latest
steps:
- uses: cisagov/setup-env-github-action@develop
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Setup cache # GitHub support coming soon
run: mkdir -p $CURL_CACHE_DIR
- name: Install Packer
run: |
PACKER_ZIP="packer_${PACKER_VERSION}_linux_amd64.zip"
curl --output "${CURL_CACHE_DIR}/${PACKER_ZIP}" \
--time-cond "${CURL_CACHE_DIR}/${PACKER_ZIP}" --location \
"https://releases.hashicorp.com/packer/${PACKER_VERSION}/${PACKER_ZIP}"
sudo unzip -o -d /usr/local/bin "${CURL_CACHE_DIR}/${PACKER_ZIP}"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade -r requirements-test.txt
- name: Validate Packer configuration
run: packer validate src/packer.json
- name: Run tests
env:
GITHUB_RELEASE_TAG: ${{ github.event.release.tag_name }}
run: pytest
57 changes: 57 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: prerelease

on:
release:
types: [prereleased]

env:
AWS_DEFAULT_REGION: us-east-2
BUILD_REGION: us-east-2
CURL_CACHE_DIR: $HOME/.cache/curl
DEPLOY_REGION_KMS_MAP: "us-east-2:alias/cool/ebs"

jobs:
prerelease:
runs-on: ubuntu-latest
steps:
- uses: cisagov/setup-env-github-action@develop
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Setup cache # GitHub support coming soon
run: mkdir -p $CURL_CACHE_DIR
- name: Install Packer
run: |
PACKER_ZIP="packer_${PACKER_VERSION}_linux_amd64.zip"
curl --output "${CURL_CACHE_DIR}/${PACKER_ZIP}" \
--time-cond "${CURL_CACHE_DIR}/${PACKER_ZIP}" --location \
"https://releases.hashicorp.com/packer/${PACKER_VERSION}/${PACKER_ZIP}"
sudo unzip -o -d /usr/local/bin "${CURL_CACHE_DIR}/${PACKER_ZIP}"
- name: Install Terraform
run: |
TERRAFORM_ZIP="terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
curl --output "${CURL_CACHE_DIR}/${TERRAFORM_ZIP}" \
--time-cond "${CURL_CACHE_DIR}/${TERRAFORM_ZIP}" --location \
"https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/${TERRAFORM_ZIP}"
sudo unzip -d /opt/terraform "${CURL_CACHE_DIR}/${TERRAFORM_ZIP}"
sudo ln -s /opt/terraform/terraform /usr/bin/terraform
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade -r requirements.txt
- name: Install ansible roles
run: ansible-galaxy install --force --role-file src/requirements.yml
- name: Patch Packer configuration
run: |
echo $DEPLOY_REGION_KMS_MAP | \
./patch_packer_config.py src/packer.json
- name: Create machine image
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_IS_PRERELEASE: ${{ github.event.release.prerelease }}
GITHUB_RELEASE_TAG: ${{ github.event.release.tag_name }}
GITHUB_RELEASE_URL: ${{ github.event.release.html_url }}
run: packer build --timestamp-ui src/packer.json
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
name: release

on:
release:
types: [released]

env:
AWS_DEFAULT_REGION: us-east-2
BUILD_REGION: us-east-2
CURL_CACHE_DIR: $HOME/.cache/curl
DEPLOY_REGION_KMS_MAP: "us-east-1:alias/cool/ebs,
us-east-2:alias/cool/ebs,
us-west-1:alias/cool/ebs,
us-west-2:alias/cool/ebs"

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: cisagov/setup-env-github-action@develop
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Setup cache # GitHub support coming soon
run: mkdir -p $CURL_CACHE_DIR
- name: Install Packer
run: |
PACKER_ZIP="packer_${PACKER_VERSION}_linux_amd64.zip"
curl --output "${CURL_CACHE_DIR}/${PACKER_ZIP}" \
--time-cond "${CURL_CACHE_DIR}/${PACKER_ZIP}" --location \
"https://releases.hashicorp.com/packer/${PACKER_VERSION}/${PACKER_ZIP}"
sudo unzip -o -d /usr/local/bin "${CURL_CACHE_DIR}/${PACKER_ZIP}"
- name: Install Terraform
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the install of packer and terraform be broken out into a separate repo a la what you did with cisagov/setup-env-github-action?

Seems maybe the Ansible role stuff could possibly be broken out as well, taking the list of role names as an input.

run: |
TERRAFORM_ZIP="terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
curl --output "${CURL_CACHE_DIR}/${TERRAFORM_ZIP}" \
--time-cond "${CURL_CACHE_DIR}/${TERRAFORM_ZIP}" --location \
"https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/${TERRAFORM_ZIP}"
sudo unzip -d /opt/terraform "${CURL_CACHE_DIR}/${TERRAFORM_ZIP}"
sudo ln -s /opt/terraform/terraform /usr/bin/terraform
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade -r requirements.txt
- name: Install ansible roles
run: ansible-galaxy install --force --role-file src/requirements.yml
- name: Patch Packer configuration
run: |
echo $DEPLOY_REGION_KMS_MAP | \
./patch_packer_config.py src/packer.json
- name: Create machine image
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_IS_PRERELEASE: ${{ github.event.release.prerelease }}
GITHUB_RELEASE_TAG: ${{ github.event.release.tag_name }}
GITHUB_RELEASE_URL: ${{ github.event.release.html_url }}
run: packer build --timestamp-ui src/packer.json
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.18.0
rev: v0.19.0
hooks:
- id: markdownlint
args:
- --config=.mdl_config.json
- repo: https://github.com/adrienverge/yamllint
rev: v1.17.0
rev: v1.18.0
hooks:
- id: yamllint
- repo: https://github.com/detailyang/pre-commit-shell
Expand All @@ -43,7 +43,7 @@ repos:
additional_dependencies:
- flake8-docstrings
- repo: https://github.com/asottile/pyupgrade
rev: v1.23.0
rev: v1.25.1
hooks:
- id: pyupgrade
# Run bandit on "tests" tree with a configuration
Expand All @@ -57,7 +57,7 @@ repos:
- --config=.bandit.yml
# Run bandit everything but tests directory
- repo: https://github.com/PyCQA/bandit
rev: 2a1dbab
rev: 1.6.2
hooks:
- id: bandit
name: bandit (everything else)
Expand All @@ -67,7 +67,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.1.1a0
rev: 7a2221a32968f12bee8494caf978ce150ad1494f
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you open an issue to remind us to change this back to a release (when one becomes available)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to backport this change up to skeleton-generic. I'll modify the issue that is up there: cisagov/skeleton-generic#19

hooks:
- id: ansible-lint
# files: molecule/default/playbook.yml
Expand Down
104 changes: 0 additions & 104 deletions .travis.yml

This file was deleted.

Loading