Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
vggonzal authored and vggonzal committed Aug 17, 2023
1 parent cc9c3a5 commit 7a07e48
Showing 1 changed file with 65 additions and 49 deletions.
114 changes: 65 additions & 49 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
env:
POETRY_VERSION: "1.3.1"
PYTHON_VERSION: "3.10"
PROJECT_ NAME: podaac/hydrocron
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

Expand All @@ -39,10 +40,13 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ env.POETRY_VERSION }}


- name: Install bumpver & poetry
run: pip3 install bumpver poetry poetry-plugin-bundle
- name: Install dependencies
run: poetry install

- name: Get version
id: get-version
run: |
Expand Down Expand Up @@ -91,34 +95,21 @@ jobs:
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
echo "venue=ops" >> $GITHUB_ENV
- name: Install hydrocron
run: poetry install
#if: ${{ startsWith(github.ref, 'test') }}
run: |
poetry update
poetry install
- name: Lint
if: ${{ startsWith(github.ref, 'test') }}
run: |
poetry run pylint hydrocronapi
poetry run flake8 hydrocronapi
## Set environment variables
- name: Configure Initial YAML file and environment variables
- name: Install external libraries
#if: ${{ startsWith(github.ref, 'test') }}
run: |
echo "THE_VERSION=${{ env.software_version }}" >> $GITHUB_ENV;
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV;
GITHUB_REF_READABLE="${GITHUB_REF//\//-}"
echo "GITHUB_REF_READABLE=${GITHUB_REF_READABLE}" >> $GITHUB_ENV
echo "THE_ENV=sit" >> $GITHUB_ENV
echo "TARGET_ENV_UPPERCASE=SIT" >> $GITHUB_ENV
# Setup Node to install and test
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 14

- name: NPM install
run:
npm install

- name: Run Snyk as a blocking step
if: ${{ startsWith(github.ref, 'test') }}
uses: snyk/actions/python-3.9@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
Expand All @@ -130,6 +121,7 @@ jobs:
--severity-threshold=high
--fail-on=all
- name: Run Snyk on Python
if: ${{ startsWith(github.ref, 'test') }}
uses: snyk/actions/python-3.9@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
Expand All @@ -150,10 +142,10 @@ jobs:
git commit -am "/version ${{ env.software_version }}"
git push
- name: Push Tag
if: |
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release')
#if: |
# github.ref == 'refs/heads/develop' ||
# github.ref == 'refs/heads/main' ||
# startsWith(github.ref, 'refs/heads/release')
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
Expand All @@ -162,27 +154,50 @@ jobs:
- name: Build Python Artifact
run: |
poetry build
poetry self add poetry-plugin-bundle
#- name: Setup local DynamoDB
# run: docker run -d -p 8000:8000 amazon/dynamodb-local
- name: Setup local DynamoDB
if: ${{ startsWith(github.ref, 'test') }}
run: docker run -d -p 8000:8000 amazon/dynamodb-local

- name: Load sample
if: ${{ startsWith(github.ref, 'test') }}
run: python3 tests/example_load_data.py

#- name: Load sample
# run: python3 tests/example_load_data.py
- name: Test with pytest
if: ${{ startsWith(github.ref, 'test') }}
run: pytest tests/test_api.py

#- name: Test with pytest
# run: pytest tests/test_api.py



## Set environment variables
- name: Configure Initial YAML file and environment variables
run: |
echo "THE_VERSION=${{ env.software_version }}" >> $GITHUB_ENV;
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV;
GITHUB_REF_READABLE="${GITHUB_REF//\//-}"
echo "GITHUB_REF_READABLE=${GITHUB_REF_READABLE}" >> $GITHUB_ENV
echo "THE_ENV=sit" >> $GITHUB_ENV
echo "TARGET_ENV_UPPERCASE=SIT" >> $GITHUB_ENV
# Setup Node to install and test
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 14

- name: NPM install & NPM Lint
run:
npm install
npm run lint

# Setup Terraform to Deploy

- name: Configure AWS Credentials as Environment Variables
run: echo "AWS_ACCESS_KEY_ID=${{ secrets[format('AWS_ACCESS_KEY_ID_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}" >> $GITHUB_ENV |
echo "AWS_SECRET_ACCESS_KEY=${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}" >> $GITHUB_ENV

- name: Validate AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -209,20 +224,21 @@ jobs:
path: dist/*.zip

- name: Deploy Terraform
#if: |
# github.ref == 'refs/heads/develop' ||
# github.ref == 'refs/heads/main' ||
# startsWith(github.ref, 'refs/heads/release') ||
# github.event.head_commit.message == '/deploy sit' ||
# github.event.head_commit.message == '/deploy uat'
if: |
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release') ||
github.event.head_commit.message == '/deploy sit' ||
github.event.head_commit.message == '/deploy uat'
working-directory: terraform/
env:
AWS_ACCESS_KEY_ID: ${{ secrets[format('AWS_ACCESS_KEY_ID_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}
AWS_DEFAULT_REGION: us-west-2
AWS_ACCESS_KEY_ID: ${{ secrets[format('AWS_ACCESS_KEY_ID_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}
AWS_DEFAULT_REGION: us-west-2

run: |
source bin/config.sh ${{ env.THE_ENV }}
#terraform init -reconfigure -backend-config="bucket=podaac-services-${{ env.THE_ENV }}-terraform" -backend-config="region=us-west-2"
terraform plan -var-file=tfvars/"${{ env.THE_ENV }}".tfvars -var="app_version=${{ env.THE_VERSION }}" -out="tfplan"
terraform apply -auto-approve tfplan
terraform init -reconfigure -backend-config="bucket=podaac-services-${{ env.THE_ENV }}-terraform" -backend-config="region=us-west-2"
terraform plan -var-file=tfvars/${{ env.THE_ENV }}.tfvars -var="app_version=${{ env.THE_VERSION }}" -out="tfplan"
terraform apply -auto-approve tfplan

0 comments on commit 7a07e48

Please sign in to comment.