-
Notifications
You must be signed in to change notification settings - Fork 11
185 lines (177 loc) · 6.51 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
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 }}
lint:
name: Lint source code
runs-on: ubuntu-latest
needs: changes
#if: ${{ needs.changes.outputs.backend == 'true' }}
steps:
- uses: actions/checkout@v3
test:
name: Run tests
runs-on: ubuntu-latest
needs: lint
#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/
# 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 }}
# Install Google Chrome browser (that matches ChromeDriver version from previous Actions step)
- name: Install Google Chrome
run: |
wget -O /tmp/google_chrome.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROMEDRIVER_VERSION}-1_amd64.deb
sudo dpkg -i /tmp/google_chrome.deb
- 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
- 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
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,