-
-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI/CD workflows for GitHub Actions (#1106)
* Add CI/CD workflows for GitHub Actions Fixes #764 Partially addresses #1010 * Don't auto-deploy by default * Import a script * Apparently localhost doesn't resolve on GitHub actions? * this is better * try to simplify the matrix setup * need to quote these * A little clean up and some train names * Will it allow a blank name? * nope, it wants a name * typo: ' * need a database for this one * oops * fail on error * exit if the migrate command fails * try this * Move super scaffolding tests into a new workflow * derp * clean up * this takes a long time * Revert "this takes a long time" This reverts commit 0d88322. * Update .github/workflows/ci-cd-pipeline-main.yml Co-authored-by: Kasper Timm Hansen <[email protected]> * Don't checkout code that we're not going to use * Only run super scaffolding tests if we're in the starter repo * shorten some names --------- Co-authored-by: Kasper Timm Hansen <[email protected]>
- Loading branch information
1 parent
81d9725
commit de01b4a
Showing
15 changed files
with
437 additions
and
5 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
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,44 @@ | ||
# This workflow will ensure that when we run `rails db:migrate` that no changes are made to `db/schema.rb`. | ||
# | ||
# This workflow is pimarily meant to be called by other workflows, but it can be run manually. | ||
name: "π ~ Database Schema Check" | ||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgres:11-alpine | ||
ports: | ||
- "5432:5432" | ||
env: | ||
POSTGRES_DB: rails_test | ||
POSTGRES_USER: rails | ||
POSTGRES_PASSWORD: password | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
env: | ||
RAILS_ENV: test | ||
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" | ||
BUNDLE_JOBS: 2 | ||
BUNDLE_RETRY: 3 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Ruby and gems | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
|
||
- name: Database Schema Check | ||
id: db-schema-check | ||
run : ./.circleci/db_schema_check | ||
continue-on-error: false |
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,30 @@ | ||
# This workflow will deploy an app to heroku. | ||
# | ||
# The name of the app to deploy must be passed in. | ||
# HEROKU_API_KEY & HEROKU_EMAIL should be added to your repo secrets to provide deployment credentials. | ||
# | ||
# This workflow is pimarily meant to be called by other workflows, but it can be run manually. | ||
name: π’ ~ Deploy to Heroku | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
heroku-app-name: | ||
required: true | ||
type: string | ||
workflow_dispatch: | ||
inputs: | ||
heroku-app-name: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
heroku: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: akhileshns/[email protected] # This is the action | ||
with: | ||
heroku_api_key: ${{secrets.HEROKU_API_KEY}} | ||
heroku_app_name: ${{ inputs.heroku-app-name }} #Must be unique in Heroku | ||
heroku_email: ${{secrets.HEROKU_EMAIL}} |
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,11 @@ | ||
# This is a dummy workflow that's just here to add a bit of organization to the workflow list. | ||
# Too bad they don't allow you to hide workflows or something. | ||
name: " π« |----- Reusable Worfklows Below" | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
nothing: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: echo "Nothing to see here. Move along. π" |
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,106 @@ | ||
# This workflow will run a few super scaffolding commands and then run tests against the generated code. | ||
# | ||
# This workflow is pimarily meant to be called by other workflows, but it can be run manually. | ||
name: ποΈ ~ Run super scaffolding tests | ||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
name: "ποΈ" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# For super scaffolding tests we need to have exactly 7 runners. | ||
ci_runners: [TestSite, Project, 'Project::Step', Insight, 'Personality::Disposition', 'Personality::Observation', TestFile] | ||
services: | ||
postgres: | ||
image: postgres:11-alpine | ||
ports: | ||
- "5432:5432" | ||
env: | ||
POSTGRES_DB: rails_test | ||
POSTGRES_USER: rails | ||
POSTGRES_PASSWORD: password | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
redis: | ||
image: redis | ||
ports: | ||
- "6379:6379" | ||
# Set health checks to wait until redis has started | ||
options: >- | ||
--health-cmd "redis-cli ping" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
env: | ||
RAILS_ENV: test | ||
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" | ||
BUNDLE_JOBS: 2 | ||
BUNDLE_RETRY: 3 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Ruby and gems | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: .nvmrc | ||
cache: 'yarn' | ||
|
||
- name: asset cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
public/assets | ||
tmp/cache/assets/sprockets | ||
key: asset-cache-${{ runner.os }}-${{ github.ref }}-${{ github.sha }} | ||
restore-keys: | | ||
asset-cache-${{ runner.os }}-${{ github.ref }}-${{ github.sha }} | ||
asset-cache-${{ runner.os }}-${{ github.ref }}- | ||
asset-cache-${{ runner.os }}- | ||
- name: Set up database schema | ||
run: bin/rails db:schema:load | ||
|
||
- run: yarn install | ||
- run: yarn build | ||
- run: yarn build:css | ||
|
||
# TODO: This might be a bad idea. Maybe we should just have spring in the Gemfile all the time. | ||
- name: Allow adding of spring | ||
run: bundle config unset deployment | ||
|
||
- name: Add spring | ||
run: bundle add spring | ||
|
||
- name: 'Setup Super Scaffolding System Test' | ||
run: bundle exec test/bin/setup-super-scaffolding-system-test | ||
env: | ||
CIRCLE_NODE_INDEX: ${{ strategy.job-index }} | ||
|
||
- name: 'Run Super Scaffolding Test' | ||
run: bundle exec rails test test/system/super_scaffolding_test.rb | ||
|
||
- name: 'Run Super Scaffolding Partial Test' | ||
run: bundle exec rails test test/system/super_scaffolding_partial_test.rb | ||
|
||
- name: 'Run Super Scaffolding Incoming Webhooks Test' | ||
run: bundle exec rails test test/controllers/webhooks/incoming/some_provider_webhooks_controller_test.rb | ||
|
||
- name: Test Summary | ||
uses: test-summary/action@v2 | ||
with: | ||
paths: "test/reports/**/TEST-*.xml" | ||
if: always() |
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,98 @@ | ||
# This workflow runs the main test suite. | ||
# | ||
# This workflow is pimarily meant to be called by other workflows, but it can be run manually. | ||
name: "π§ͺ ~ Run tests" | ||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
name: "π§ͺ" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# Set identifiers for parallel jobs. These can be anything. Just include as many items as you want parallelism. | ||
# For instance if you want a Three Amigos themed pipeline you could use: | ||
# ci_node_index: [Dusty, Ned, Lucky] | ||
ci_runners: [1,2,3,4] | ||
services: | ||
postgres: | ||
image: postgres:11-alpine | ||
ports: | ||
- "5432:5432" | ||
env: | ||
POSTGRES_DB: rails_test | ||
POSTGRES_USER: rails | ||
POSTGRES_PASSWORD: password | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
redis: | ||
image: redis | ||
ports: | ||
- "6379:6379" | ||
# Set health checks to wait until redis has started | ||
options: >- | ||
--health-cmd "redis-cli ping" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
env: | ||
RAILS_ENV: test | ||
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" | ||
BUNDLE_JOBS: 2 | ||
BUNDLE_RETRY: 3 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Ruby and gems | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: .nvmrc | ||
cache: 'yarn' | ||
|
||
- name: asset cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
public/assets | ||
tmp/cache/assets/sprockets | ||
key: asset-cache-${{ runner.os }}-${{ github.ref }}-${{ github.sha }} | ||
restore-keys: | | ||
asset-cache-${{ runner.os }}-${{ github.ref }}-${{ github.sha }} | ||
asset-cache-${{ runner.os }}-${{ github.ref }}- | ||
asset-cache-${{ runner.os }}- | ||
- name: Set up database schema | ||
run: bin/rails db:schema:load | ||
|
||
- run: yarn install | ||
- run: yarn build | ||
- run: yarn build:css | ||
|
||
- name: Run Tests | ||
id: run-tests | ||
env: | ||
AUTH_ENDPOINT: https://no-site.nowhere | ||
AWS_REGION: us-east-1 | ||
CI_NODE_TOTAL: ${{ strategy.job-total }} | ||
CI_NODE_INDEX: ${{ strategy.job-index }} | ||
continue-on-error: false | ||
run : ./bin/parallel-ci | ||
shell: bash | ||
|
||
- name: Test Summary | ||
uses: test-summary/action@v2 | ||
with: | ||
paths: "test/reports/**/TEST-*.xml" | ||
if: always() |
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,27 @@ | ||
# This workflow will run standardrb. | ||
# | ||
# This workflow is pimarily meant to be called by other workflows, but it can be run manually. | ||
name: "π¬ ~ Standardrb" | ||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
env: | ||
RAILS_ENV: test | ||
BUNDLE_JOBS: 2 | ||
BUNDLE_RETRY: 3 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Ruby and gems | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
|
||
- name: Run Standardrb | ||
id: run-standardrb | ||
run : bundle exec standardrb |
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,24 @@ | ||
# This workflow will run whenever a PR is opened or changed. | ||
# | ||
# It will run tests and a few safety checks. | ||
# | ||
# If everything passes it can be set to auto-deploy to your staging app on Heroku. | ||
# | ||
# This workflow is primarily meant to be triggered automatically, but it can be run manually. | ||
name: " π _ BT - Internal CI" | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
push: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
super_scaffolding: | ||
# This makes it so that this job only runs in the starter repo itself, and not in | ||
# applications started from the starter repo. If you want to run super scaffolding | ||
# test for your own app you can remove or comment out this next line. | ||
if: github.repository == 'bullet-train-co/bullet_train' | ||
name: ποΈ Super Scaffolding Tests | ||
uses: ./.github/workflows/_run_super_scaffolding_tests.yml | ||
secrets: inherit |
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,36 @@ | ||
# This workflow will run whenever commits land on the main branch. | ||
# | ||
# It will run tests and a few safety checks. | ||
# | ||
# If everything passes it can be set to auto-deploy to your production app on Heroku. | ||
# | ||
# This workflow is primarily meant to be triggered automatically, but it can be run manually. | ||
name: " π₯ Main CI (prod)" | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
minitest: | ||
name: π§ͺ Minitest | ||
uses: ./.github/workflows/_run_tests.yml | ||
secrets: inherit | ||
standardrb: | ||
name: π¬ Standardrb | ||
uses: ./.github/workflows/_standardrb.yml | ||
secrets: inherit | ||
db_schema: | ||
name: π DB Schema | ||
uses: ./.github/workflows/_database_schema_check.yml | ||
secrets: inherit | ||
# If you'd like to auto-deploy to your production environment you can uncomment this next block. | ||
# You'll need to set HEROKU_EMAIL and HEROKU_API_KEY in your repo secrets. | ||
# Be sure to set the app name correctly below. | ||
# deploy: | ||
# name: π’ Deploy to Heroku | ||
# uses: ./.github/workflows/_deploy_heroku.yml | ||
# needs: [mini_test, standardrb, db_schema] | ||
# secrets: inherit | ||
# with: | ||
# heroku-app-name: "" |
Oops, something went wrong.