Skip to content

Merge pull request #1349 from concord-consortium/187613639-perm-form-… #850

Merge pull request #1349 from concord-consortium/187613639-perm-form-…

Merge pull request #1349 from concord-consortium/187613639-perm-form-… #850

Workflow file for this run

name: CI
on: push
jobs:
changes:
name: Filter jobs based on changes
runs-on: ubuntu-latest
outputs:
backend: ${{ steps.filter.outputs.backend }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
backend:
- 'rails/**'
- if: steps.changes.outputs.backend == 'true'
run: echo ${{ steps.changes.outputs.backend }}
test:
name: Run tests
runs-on: ubuntu-latest
#if: ${{ needs.changes.outputs.backend == 'true' }}
strategy:
matrix:
include:
- test_suite: spec_without_webdriver
env: test
- test_suite: spec_with_webdriver
env: test
- test_suite: cucumber_without_javascript
env: cucumber
- test_suite: cucumber_javascript
env: cucumber
- test_suite: cucumber_search
env: cucumber
services:
# Label used to access the service container
database:
image: mariadb:10.10
ports:
- 3306:3306 # Map TCP port from service container to runner host
env:
MARIADB_USER: actions
MARIADB_PASSWORD: password123
MARIADB_ROOT_PASSWORD: password123
MARIADB_DATABASE: ${{ github.event.repository.name }}_test
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes # Allow the container to be started with a blank password for the root user
solr:
image: concordconsortium/docker-solr-portal
ports:
- 8981:8983
env:
TEST_SOLR_PORT: 8981
env:
RAILS_ENV: ${{ matrix.env }}
CHROMEDRIVER_VERSION: '114.0.5735.90'
defaults:
run:
working-directory: ./rails/
steps:
- uses: actions/checkout@v3
- name: Print $RAILS_ENV
run: echo $RAILS_ENV
- uses: ruby/setup-ruby@v1
name: Setup Ruby
with:
bundler-cache: true # use Actions cache to significantly speed up subsequent runs
working-directory: ./rails/
- uses: actions/setup-node@v4
with:
node-version: '18.18.0'
# Install ChromeDriver (wiping out whatever version was previously installed on Actions Runner)
- name: Install ChromeDriver
uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: ${{ env.CHROMEDRIVER_VERSION }}
# Remove existing Google Chrome as ChromeDriver will default to it (setup-chrome installs under /opt/hostedtoolcache/setup-chrome/)
- name: Remove Existing Google Chrome (so ChromeDriver doesn't use it instead of manually installed version)
run: sudo apt-get remove google-chrome-stable
# Install Google Chrome browser (that matches ChromeDriver version from previous Actions step)
- name: Install Google Chrome
id: install-chrome
uses: browser-actions/setup-chrome@v1
with:
chrome-version: ${{ env.CHROMEDRIVER_VERSION }}
- run: cp -v ./config/database.github_actions.yml ./config/database.yml
- run: cp -v ./config/app_environment_variables.sample.rb ./config/app_environment_variables.rb
- run: cp -v ./config/settings.sample.yml ./config/settings.yml
# See: https://github.com/concord-consortium/rigse/blob/master/rails/script/travis_before_script#L17-L20
- run: bundle exec rake db:create
env:
RAILS_ENV: test
- run: bundle exec rake db:create
env:
RAILS_ENV: cucumber
- run: bundle exec rake db:schema:load
- run: bundle exec rake db:migrate
- run: bundle exec rake db:test:prepare
- run: bundle exec rake db:feature_test:prepare
- run: bundle exec rake app:setup:create_default_data
env:
RAILS_ENV: cucumber
- name: Install react-components dependencies
working-directory: ./rails/react-components/
run: npm ci
- name: Build react-components (before assets:precompile!)
working-directory: ./rails/react-components/
run: npm run build
- run: bundle exec rake assets:precompile
name: Precompile assets
env:
RAILS_GROUPS: assets
- run: bundle exec rake ci:${{ matrix.test_suite }}
name: Run Rake ci:${{ matrix.test_suite }} task
test-react-components:
name: Run react-components tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./rails/react-components/
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: '18.18.0'
- name: Install react-components dependencies
working-directory: ./rails/react-components/
run: npm ci
- name: Lint react-components
working-directory: ./rails/react-components/
run: npm run lint
- name: Build react-components
working-directory: ./rails/react-components/
run: npm run build
- name: Test react-components
working-directory: ./rails/react-components/
run: npm run test
build:
name: Build Docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# See: https://github.com/docker/login-action#github-container-registry
- name: Login to GitHub Container Registry (GHCR)
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
## See: https://github.com/docker/login-action#docker-hub
#- name: Login to Docker Hub
# uses: docker/login-action@v2
# if: ${{ secrets.DOCKER_HUB_USERNAME != '' && secrets.DOCKER_HUB_TOKEN != '' && env.DOCKER_HUB_IMAGE }}
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Extract metadata for Docker image tagging
id: docker_metadata
uses: docker/metadata-action@v4
with:
images: |-
${{ env.REGISTRY }}/${{ github.repository }}
# "refs/tags/v1.2.3" --> "1.2.3" (drop "v" prefix just like official Docker Hub images)
tags: |-
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=sha,prefix=git-
- name: Build & push Docker image
uses: docker/build-push-action@v4
with:
#context: '{{defaultContext}}:rails'
context: ./rails/
push: ${{ env.ACT != 'true' }} # Don't attempt to publish a GitHub package when running Actions locally using "act"
# Use GitHub Actions cache (see https://docs.docker.com/build/building/cache/backends/gha/#using-dockerbuild-push-action)
cache-from: type=gha
cache-to: type=gha,mode=max
labels: ${{ steps.docker_metadata.outputs.labels }}
tags: ${{ steps.docker_metadata.outputs.tags }}
build-args: |-
CC_PORTAL_VERSION=${{ github.ref_name }}
deploy:
name: Deploy application
needs: build
runs-on: ubuntu-latest
if: false
steps:
- name: Deploy to AWS CloudFormation
uses: aws-actions/aws-cloudformation-github-deploy@6901756
with:
name: learn-ecs-staging
template: ./configs/cloudformation/stack_template.yml
parameter-overrides: >-
PortalDockerImage=TODO,