Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
3c05bcc
Add GitHub Actions for lints and tests
reweeden Jan 10, 2022
8a233a7
Combine flake8 and isort checks with flake8-isort plugin
reweeden Jan 10, 2022
b6685b9
Add setup.cfg
reweeden Jan 11, 2022
4c16670
Sort imports
reweeden Jan 11, 2022
1632b98
Fix flake8 errors
reweeden Jan 12, 2022
2bbe641
Add dummy test folder
reweeden Jan 13, 2022
11a769f
Add codecov
reweeden Jan 13, 2022
4111c9c
Add codecov badge to readme
reweeden Jan 13, 2022
a5d30cd
Fix trailing whitespace in readme
reweeden Jan 13, 2022
dea6333
Merge pull request #441 from asfadmin/pr-2930-add-github-actions
benbart Jan 13, 2022
470f004
Move requirements.txt to top level
reweeden Jan 6, 2022
2374818
Install rain-api-core from git
reweeden Jan 6, 2022
fb44788
Clean up file formatting
reweeden Jan 6, 2022
86eb1f7
Set up tests directory
reweeden Jan 7, 2022
0cedb20
Add tests
reweeden Jan 11, 2022
faeb056
Refactor and reformat various minor things
reweeden Jan 11, 2022
6b1ebe6
Refactor caching with cachetools
reweeden Jan 11, 2022
cd7d6d0
Rename send_cors_headers
reweeden Jan 11, 2022
cc951ed
Refactor string split
reweeden Jan 11, 2022
ea5611e
Remove unused `version` function
reweeden Jan 18, 2022
1fd849e
Remove other unused objects
reweeden Jan 18, 2022
e144d3a
Move test resource helpers to conftest
reweeden Jan 19, 2022
dc3aea0
Refactor mock.patch to use constant for module name and autospecing
reweeden Jan 19, 2022
780151a
Use unused mocks
reweeden Jan 19, 2022
29690d6
Set up boto config environment variables
reweeden Jan 21, 2022
7821285
Make module name variable consistent
reweeden Jan 21, 2022
b7db1a8
Merge pull request #440 from asfadmin/rew/pr-2930-add-unit-tests
benbart Jan 25, 2022
3e05f3a
Remove all dependencies not directly used by TEA
reweeden Jan 24, 2022
2453600
Bump dependency versions
reweeden Jan 24, 2022
f85278a
Merge pull request #443 from asfadmin/rew/pr-3041-update-dependencies
benbart Jan 26, 2022
a8ec301
Fix dependency builder
reweeden Jan 18, 2022
6f24326
Remove unused parts of dependencies
reweeden Jan 24, 2022
40f523c
WIP: Add Makefile
reweeden Jan 18, 2022
0e0e155
Rework Makefile to use one name for each build artifact
reweeden Feb 2, 2022
2f1605b
Add optional deploy of bucket map
reweeden Feb 3, 2022
407e474
Update readme
reweeden Feb 3, 2022
917eda8
Rework code zip rules so that they work correctly for html files
reweeden Feb 3, 2022
bd045c1
Add config options for CloudFormation template
reweeden Feb 3, 2022
0e3f916
Add steps to build terraform zip
reweeden Feb 3, 2022
124d0c7
Use make to create build artifacts in Jenkins
reweeden Feb 3, 2022
207f69f
Rename CONFIG to Makefile.config
reweeden Feb 3, 2022
6aa3335
Make dependency layer in docker container by default
reweeden Feb 3, 2022
2666da2
Clean up formatting
reweeden Feb 3, 2022
31e5273
Cleanup Makefile and remove TODOs
reweeden Feb 4, 2022
a46e531
Add notes about development to readme
reweeden Feb 4, 2022
9aaba57
Create directories in rules instead of order-only dependencies
reweeden Feb 4, 2022
44181f6
Recreate dependency staging dir from scratch each time
reweeden Feb 4, 2022
3bb677f
Split multiline echo into multiple commands
reweeden Feb 5, 2022
30b29a9
Replace date `--utc` with `-u` for Mac support
reweeden Feb 5, 2022
ca59935
Add 'all' target
reweeden Feb 8, 2022
7eb0262
Use semicolon for sed command delimiter
reweeden Feb 8, 2022
095f7f7
Fix default s3 keys
reweeden Feb 8, 2022
06ecc91
Add compatibility with BSD version of `sed`
reweeden Feb 9, 2022
51c22f6
Replace calls to `sed` command with a python script for OS compatibility
reweeden Feb 9, 2022
ce123b2
Remove type annotations for python version compatibility
reweeden Feb 10, 2022
4fd25e5
Fix default bucketmap deployment
reweeden Feb 10, 2022
8712879
Clarify in config that required args are only required for deploy
reweeden Feb 11, 2022
d457588
Avoid overwriting the bucket map after it's been created
reweeden Feb 11, 2022
e945a59
Improve Mac compatibility
reweeden Feb 11, 2022
34310de
Remove existence checks
reweeden Feb 11, 2022
c7753a3
Merge pull request #452 from asfadmin/rew/pr-3033-add-a-makefile
benbart Feb 14, 2022
f6e8a12
Update dev dependencies
reweeden Feb 14, 2022
5261b6c
Update dependencies
reweeden Feb 14, 2022
739c583
Merge pull request #458 from asfadmin/rew/update-dependencies
reweeden Feb 14, 2022
d6ae698
Fix some issues in download_test
reweeden Feb 1, 2022
feddb5d
Rewrite end to end tests with pytest
reweeden Feb 1, 2022
86b193e
Run pytest end to end tests in Jenkins
reweeden Feb 1, 2022
60cced7
Remove download_test.py
reweeden Feb 1, 2022
003e735
Separate layers out in dockerfile
reweeden Feb 14, 2022
a7676e1
Merge pull request #450 from asfadmin/rew/pr-3066-convert-e2e-to-pytest
mckadesorensen Feb 14, 2022
0651dbd
Compile pattern in multiline mode
reweeden Feb 16, 2022
c533cb8
Merge pull request #460 from asfadmin/rew/fix-make-build
benbart Feb 16, 2022
e94177b
Add github actions
reweeden Feb 7, 2022
a114812
Refactor to reusable workflows
reweeden Feb 15, 2022
221a1e5
Add readme
reweeden Feb 15, 2022
6b78b66
Upload build artifacts to release
reweeden Feb 16, 2022
3f8ce0d
Move test configuration to checked in env file
reweeden Feb 16, 2022
e71ff4e
Default to not running tests
reweeden Feb 16, 2022
37d8774
Adjust status reporting failure detection
reweeden Feb 17, 2022
af86593
Refactor config files and add one for prod
reweeden Feb 17, 2022
e3aad7c
Rename workflows
reweeden Feb 17, 2022
59085bf
Merge pull request #1 from benbart/rew/pr-3080-gh-actions-release
benbart Feb 21, 2022
ab0a2c6
bbarton-dev code bucket
benbart Feb 21, 2022
f259f18
update prodenv with bbarton vars
benbart Feb 21, 2022
b5be9aa
forcing build
benbart Feb 21, 2022
057df2c
Update test.env
benbart Feb 21, 2022
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
85 changes: 85 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# GitHub Actions Workflows
These workflows define a CI/CD pipeline that is intended to work both for the
main repo and for forks.

GitHub Actions workflows overview:
- Run unit tests and style checks against PR's
- Run end-to-end tests whenever a PR is merged
- Build and publish zip/yaml files needed to spin up a TEA stack on releases

In order for the end-to-end tests to run you need to set the `RUN_TESTS` secret
in your repository secrets to `true`. However, currently these tests assume
they are running in ASF's environment, so enabling them is probably not desired
on forked repos, hence they are disabled by default. All other secrets are
stored in GitHub environments.

## Environments
There are two environments used to control which AWS resources will be modified
by GitHub Actions. The `prod` environment is used for pushing finished build
artifacts and build status files to a public bucket. The `test` environment is
used for deploying a test stack and running the end-to-end tests against it.
Unless you enable the end-to-end tests with the `RUN_TESTS` repository secret,
you don't need to configure any secrets in the `test` environment.

- prod
- AWS Credentials (see below)
- test
- AWS Credentials (see below)
- `URS_USERNAME` URS username used by end-to-end tests for authenticated
downloads
- `URS_PASSWORD` URS password used by end-to-end tests for authenticated
downloads
- If the config file doesn't specify a value for `URS_AUTH_CREDS_SECRET_NAME`,
the following secrets are also needed:
- `URS_CLIENT_ID`
- `EDL_APP_UID`
- `EDL_APP_PASSWORD`

### Setting up AWS Credentials
- `AWS_ACCESS_KEY_ID`
- `AWS_SECRET_ACCESS_KEY`
- (optional) `AWS_ROLE_ARN`
- (optional) `AWS_REGION`

## Config file
Unfortunately, GitHub currently doesn't support non-secret configuration
variables. Therefore all non-secret configuration is stored in `.env`
files located in the `config-public` directory. The file names correspond to
the environment names that the configuraiton belongs to. After forking the repo,
you can commit changes to these files to adjust the setup for your use case.

### Build Configuration
The build configuration is located in `prod.env` and includes the following
options:

- `CODE_BUCKET` Bucket to upload build results to. Needs to allow public ACL.
- (optional) `CODE_PREFIX` All objects uploaded to the code bucket get
this prefix

### Test Configuration
The end-to-end test configuration is located in `test.env` and includes the
following options:

- `BUCKET_MAP_FILE` Name of the bucket map file to use from the config
bucket.
- `BUCKETNAME_PREFIX`
- `CODE_BUCKET` Bucket to upload build results to for testing. Probably a
private bucket.
- `CODE_PREFIX` All objects uploaded to the code bucket get this prefix.
- `CONFIG_BUCKET` Bucket containing configuration files such as
the bucket map. Defaults to `CODE_BUCKET`
- `COOKIE_DOMAIN`
- `DOMAIN_CERT_ARN`
- `DOMAIN_NAME`
- `JWT_KEY_SECRET_NAME` Name of the AWS SecretsManager secret
containing the JWT public and private keys. This can be omitted and a
secret will be created automatically with a newly generated key pair.
- `STACK_NAME` Name of the CloudFormation stack to update
- `URS_AUTH_CREDS_SECRET_NAME` Name of the AWS SecretsManager
secret containing URS client id and client secret. This can be omitted
and a secret will be created automatically using the following github
environment secrets:
- `URS_CLIENT_ID`
- `EDL_APP_UID`
- `EDL_APP_PASSWORD`
- `URS_URL` URL to use for Earthdata login.
2 changes: 2 additions & 0 deletions .github/workflows/config-public/prod.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CODE_BUCKET=bbarton-dev
CODE_PREFIX=thin-egress-app-prodbuild/
13 changes: 13 additions & 0 deletions .github/workflows/config-public/test.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
BUCKET_MAP_FILE=bucket_map_customheaders.yaml
BUCKETNAME_PREFIX=rain-uw2-t-
CODE_BUCKET=bbarton-dev
CODE_PREFIX=thin-egress-app-benbart/
CONFIG_BUCKET=rain-uw2-t-config
COOKIE_DOMAIN=.asf.alaska.edu
DOMAIN_CERT_ARN=arn:aws:acm:us-east-1:117169578524:certificate/1f3945cf-cac7-4d75-ad8d-b8920534fea2
DOMAIN_NAME=tea-test-jenk-0.asf.alaska.edu
JWT_KEY_SECRET_NAME=
STACK_NAME=teatest-jenk-same
URS_AUTH_CREDS_SECRET_NAME=URS_creds_ASF_DATA_ACCESS_EGRESS_CONTROL
URS_URL=https://urs.earthdata.nasa.gov
FOO=BAR
18 changes: 18 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint
on:
pull_request:

jobs:
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8

- run: pip install -r requirements.txt

- uses: TrueBrain/actions-flake8@v2
with:
plugins: flake8-isort
96 changes: 96 additions & 0 deletions .github/workflows/re-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Reusable workflow for building artifacts
name: Build

on:
workflow_call:
inputs:
environment:
required: true
type: string

outputs:
version:
value: ${{ jobs.variables.outputs.version }}
code-zip:
value: ${{ jobs.variables.outputs.code-zip }}
dependency-zip:
value: ${{ jobs.variables.outputs.dependency-zip }}
cloudformation-yaml:
value: ${{ jobs.variables.outputs.cloudformation-yaml }}
terraform-zip:
value: ${{ jobs.variables.outputs.terraform-zip }}


jobs:
# Generate some names from the version info in the tag name
variables:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.step1.outputs.version }}
code-zip: ${{ steps.step1.outputs.code-zip }}
dependency-zip: ${{ steps.step1.outputs.dependency-zip }}
cloudformation-yaml: ${{ steps.step1.outputs.cloudformation-yaml }}
terraform-zip: ${{ steps.step1.outputs.terraform-zip }}

steps:
- id: step1
run: |
VERSION=${GITHUB_REF_NAME#*.}
echo "::set-output name=version::$VERSION"
echo "::set-output name=code-zip::tea-code-build.$VERSION.zip"
echo "::set-output name=dependency-zip::tea-dependencylayer-build.$VERSION.zip"
echo "::set-output name=cloudformation-yaml::tea-cloudformation-build.$VERSION.yaml"
echo "::set-output name=terraform-zip::tea-terraform-build.$VERSION.zip"

# Build everything
build-all:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
needs: variables

steps:
- uses: actions/checkout@v2

- name: Load environment defaults
run: cat .github/workflows/config-public/${{ inputs.environment }}.env >> $GITHUB_ENV

- name: Set Makefile.config
run: |
TIMESTAMP=$(TZ=America/Anchorage date)

cat > Makefile.config << EOF
BUILD_ID := ${{ needs.variables.outputs.version }}

CF_DEFAULT_CODE_BUCKET := ${{ env.CODE_BUCKET }}
CF_DEFAULT_DEPENDENCY_ARCHIVE_KEY := ${{ env.CODE_PREFIX }}${{ needs.variables.outputs.code-zip }}
CF_DEFAULT_CODE_ARCHIVE_KEY := ${{ env.CODE_PREFIX }}${{ needs.variables.outputs.dependency-zip }}
CF_BUILD_VERSION := \$(BUILD_ID)
CF_DESCRIPTION := TEA version ${{ needs.variables.outputs.version }} (${GITHUB_SHA:0:7}) built by GitHub Actions on $TIMESTAMP.
EOF

- name: Build artifacts
run: make build

- name: Save dependency layer zip
uses: actions/upload-artifact@v2
with:
name: dependency-layer
path: dist/thin-egress-app-dependencies.zip

- name: Save Lambda code
uses: actions/upload-artifact@v2
with:
name: code
path: dist/thin-egress-app-code.zip

- name: Save CloudFormation yaml
uses: actions/upload-artifact@v2
with:
name: cloudformation
path: dist/thin-egress-app.yaml

- name: Save Terraform zip
uses: actions/upload-artifact@v2
with:
name: terraform
path: dist/thin-egress-app-terraform.zip
91 changes: 91 additions & 0 deletions .github/workflows/re-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Reusable workflow for reporting build status
name: Status

on:
workflow_call:
inputs:
environment:
required: true
type: string
build_tag:
required: true
type: string
success:
required: true
type: boolean

secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
# Optional
AWS_ROLE_ARN:
required: false
AWS_REGION:
required: false


jobs:
report-success:
if: inputs.success
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}

steps:
- uses: actions/checkout@v2

- name: Load environment defaults
run: cat .github/workflows/config-public/${{ inputs.environment }}.env >> $GITHUB_ENV

- uses: actions/download-artifact@v2

- name: Upload success labels
run: |
mkdir -p buildreport
echo '{"schemaVersion": 1, "label": "Build Status", "message": "Success", "color": "success"}' > buildreport/buildstatus.json
echo '{"schemaVersion": 1, "label": "Last Successful Build", "message": "${{ inputs.build_tag }}", "color": "success"}' > buildreport/lastgoodbuild.json
echo '{"schemaVersion": 1, "label": "Last Build", "message": "${{ inputs.build_tag }}", "color": "success"}' > buildreport/lastbuild.json
aws s3 cp buildreport/ "s3://${CODE_BUCKET}/thin-egress-app/" \
--recursive \
--metadata-directive REPLACE \
--cache-control no-cache \
--expires '2016-06-14T00:00:00Z' \
--content-type 'application/json' \
--acl public-read

report-failures:
if: ${{ !inputs.success }}
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}

steps:
- uses: actions/checkout@v2

- name: Load environment defaults
run: cat .github/workflows/config-public/${{ inputs.environment }}.env >> $GITHUB_ENV

- uses: actions/download-artifact@v2

- name: Upload failure labels
run: |
mkdir -p buildreport
echo '{"schemaVersion": 1, "label": "Build Status", "message": "Failed!", "color": "critical"}' > buildreport/buildstatus.json
echo '{"schemaVersion": 1, "label": "Last Build", "message": "${{ inputs.build_tag }}", "color": "critical"}' > buildreport/lastbuild.json
aws s3 cp buildreport/ "s3://${CODE_BUCKET}/thin-egress-app/" \
--recursive \
--metadata-directive REPLACE \
--cache-control no-cache \
--expires '2016-06-14T00:00:00Z' \
--content-type 'application/json' \
--acl public-read
Loading