-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I have refactored our GitHub actions to allow us to trigger deployments.
I have removed the existing scripts related to the build_test on AWS. I have also moved the unit-test and feature-test jobs into separate workflows so they can be reused in other workflows. I have created the workflow which should (hopefully) then deploy the code to the correct environments, but this still needs to be tested and sorted.
- Loading branch information
Showing
6 changed files
with
200 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: "Deploy latest code to AWS" | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
- master | ||
- preview | ||
- production | ||
|
||
jobs: | ||
determine-environment: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
env_name: ${{ steps.determine_environment.outputs.env_name }} | ||
steps: | ||
- name: Determine the environment to deploy to | ||
id: determine_environment | ||
run: | | ||
echo "Running on branch ${{ github.ref }}" | ||
if [ "${{ github.ref }}" = "refs/heads/master" ]; then | ||
echo "::set-output name=env_name::CMPDEV" | ||
elif [ "${{ github.ref }}" = "refs/heads/develop" ]; then | ||
echo "::set-output name=env_name::Sandbox" | ||
elif [ "${{ github.ref }}" = "refs/heads/preview" ]; then | ||
echo "::set-output name=env_name::Preview" | ||
elif [ "${{ github.ref }}" = "refs/heads/production" ]; then | ||
echo "::set-output name=env_name::Production" | ||
else | ||
echo "::set-output name=env_name::FAIL" | ||
fi | ||
- name: Fail if not an environment | ||
run: | | ||
echo "ERROR: No environment found" | ||
exit 1 | ||
if: steps.determine_environment.outputs.env_name == 'FAIL' | ||
|
||
- name: Show where we are deploying to | ||
run: echo "We will deploy to ${{ steps.determine_environment.outputs.env_name }}" | ||
|
||
run-unit-tests: | ||
needs: | ||
- determine-environment | ||
uses: ./.github/workflows/unit_tests.yaml | ||
|
||
run-feature-tests: | ||
needs: | ||
- determine-environment | ||
uses: ./.github/workflows/feature_tests.yaml | ||
with: | ||
run_all_feature_tests: true | ||
|
||
deploy-to-application: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- determine-environment | ||
- run-unit-tests | ||
- run-feature-tests | ||
environment: | ||
name: ${{ needs.determine-environment.outputs.env_name }} | ||
steps: | ||
- name: Trigger AWS CodePipeline - main container | ||
uses: tim-s-ccs/[email protected] | ||
with: | ||
aws-region: ${{ secrets.AWS_PIPELINE_REGION }} | ||
aws-access-key: ${{ secrets.AWS_PIPELINE_ACCESS_KEY }} | ||
aws-secret-key: ${{ secrets.AWS_PIPELINE_SECRET_KEY }} | ||
pipeline-name: ${{ secrets.AWS_PIPELINE_MAIN_NAME }} | ||
|
||
deploy-to-sidekiq: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- determine-environment | ||
- run-unit-tests | ||
- run-feature-tests | ||
environment: | ||
name: ${{ needs.determine-environment.outputs.env_name }} | ||
steps: | ||
- name: Trigger AWS CodePipeline - sidekiq container | ||
uses: tim-s-ccs/[email protected] | ||
with: | ||
aws-region: ${{ secrets.AWS_PIPELINE_REGION }} | ||
aws-access-key: ${{ secrets.AWS_PIPELINE_ACCESS_KEY }} | ||
aws-secret-key: ${{ secrets.AWS_PIPELINE_SECRET_KEY }} | ||
pipeline-name: ${{ secrets.AWS_PIPELINE_SIDEKIQ_NAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
run_all_feature_tests: | ||
description: 'A trigger to run all the feature tests instead of a subset' | ||
default: false | ||
required: false | ||
type: boolean | ||
|
||
jobs: | ||
feature-test: | ||
runs-on: ubuntu-20.04 | ||
|
||
services: | ||
postgres: | ||
image: postgis/postgis:11-2.5 | ||
ports: | ||
- "5432:5432" | ||
env: | ||
POSTGRES_DB: rails_test | ||
POSTGRES_USER: rails | ||
POSTGRES_PASSWORD: password | ||
|
||
env: | ||
RAILS_ENV: test | ||
DATABASE_URL: "postgis://rails:password@localhost:5432/rails_test" | ||
CUCUMBER_FORMAT: progress | ||
|
||
steps: | ||
- name: Setup Gecko driver | ||
uses: browser-actions/setup-geckodriver@latest | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Ruby and gems | ||
uses: ruby/[email protected] | ||
with: | ||
bundler-cache: true | ||
|
||
- name: Set up database schema | ||
run: bin/rails db:test:prepare | ||
|
||
- name: Compile assets | ||
run: bin/rails assets:precompile | ||
|
||
- name: Seed DB with test data | ||
run: bin/rails db:static | ||
|
||
- name: Run feature tests | ||
run: bin/rails cucumber:pipeline | ||
if: ${{ !inputs.run_all_feature_tests }} | ||
|
||
- name: Run all feature tests | ||
run: bin/rails cucumber:ok | ||
if: ${{ inputs.run_all_feature_tests }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,19 @@ | ||
name: "Ruby on Rails CI" | ||
|
||
on: | ||
- push | ||
- pull_request | ||
push: | ||
branches-ignore: | ||
- develop | ||
- master | ||
- preview | ||
- production | ||
pull_request: | ||
|
||
jobs: | ||
unit-test: | ||
runs-on: ubuntu-18.04 | ||
run-unit-tests: | ||
uses: ./.github/workflows/unit_tests.yaml | ||
|
||
services: | ||
postgres: | ||
image: postgis/postgis:11-2.5 | ||
ports: | ||
- "5432:5432" | ||
env: | ||
POSTGRES_DB: rails_test | ||
POSTGRES_USER: rails | ||
POSTGRES_PASSWORD: password | ||
|
||
env: | ||
RAILS_ENV: test | ||
DATABASE_URL: "postgis://rails:password@localhost:5432/rails_test" | ||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Ruby and gems | ||
uses: ruby/[email protected] | ||
with: | ||
bundler-cache: true | ||
|
||
- name: Set up database schema | ||
run: bin/rails db:test:prepare | ||
|
||
- name: Compile assets | ||
run: bin/rails assets:precompile | ||
|
||
- name: Run unit tests | ||
run: bin/rake | ||
|
||
- name: publish code coverage | ||
uses: paambaati/[email protected] | ||
with: | ||
debug: true | ||
if: github.event_name == 'pull_request' | ||
|
||
feature-test: | ||
runs-on: ubuntu-18.04 | ||
|
||
services: | ||
postgres: | ||
image: postgis/postgis:11-2.5 | ||
ports: | ||
- "5432:5432" | ||
env: | ||
POSTGRES_DB: rails_test | ||
POSTGRES_USER: rails | ||
POSTGRES_PASSWORD: password | ||
|
||
env: | ||
RAILS_ENV: test | ||
DATABASE_URL: "postgis://rails:password@localhost:5432/rails_test" | ||
CUCUMBER_FORMAT: progress | ||
|
||
steps: | ||
- name: Setup Gecko driver | ||
uses: browser-actions/setup-geckodriver@latest | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Ruby and gems | ||
uses: ruby/[email protected] | ||
with: | ||
bundler-cache: true | ||
|
||
- name: Set up database schema | ||
run: bin/rails db:test:prepare | ||
|
||
- name: Compile assets | ||
run: bin/rails assets:precompile | ||
|
||
- name: Seed DB with test data | ||
run: bin/rails db:static | ||
|
||
- name: Run feature tests | ||
run: bin/rails cucumber:pipeline | ||
if: github.event.pull_request.base.ref != 'preview' && github.event.pull_request.base.ref != 'production' | ||
|
||
- name: Run all feature tests | ||
run: bin/rails cucumber:ok | ||
if: github.event.pull_request.base.ref == 'preview' || github.event.pull_request.base.ref == 'production' | ||
run-feature-tests: | ||
uses: ./.github/workflows/feature_tests.yaml | ||
with: | ||
run_all_feature_tests: ${{ github.event.pull_request.base.ref == 'preview' || github.event.pull_request.base.ref == 'production' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
on: | ||
- workflow_call | ||
|
||
jobs: | ||
unit-test: | ||
runs-on: ubuntu-20.04 | ||
|
||
services: | ||
postgres: | ||
image: postgis/postgis:11-2.5 | ||
ports: | ||
- "5432:5432" | ||
env: | ||
POSTGRES_DB: rails_test | ||
POSTGRES_USER: rails | ||
POSTGRES_PASSWORD: password | ||
|
||
env: | ||
RAILS_ENV: test | ||
DATABASE_URL: "postgis://rails:password@localhost:5432/rails_test" | ||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Ruby and gems | ||
uses: ruby/[email protected] | ||
with: | ||
bundler-cache: true | ||
|
||
- name: Set up database schema | ||
run: bin/rails db:test:prepare | ||
|
||
- name: Compile assets | ||
run: bin/rails assets:precompile | ||
|
||
- name: Run unit tests | ||
run: bin/rake | ||
|
||
- name: publish code coverage | ||
uses: paambaati/[email protected] | ||
with: | ||
debug: true | ||
if: github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'master' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.