Merge branch 'main' into dependabot/bundler/rails-7.0.8.6 #2221
Workflow file for this run
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
name: CI | |
on: push | |
jobs: | |
build: | |
# You must use a Linux environment when using service containers or container jobs | |
runs-on: ubuntu-20.04 | |
env: | |
NOTIFY_API_KEY: ${{ secrets.NOTIFY_API_KEY }} | |
WCRS_REGISTRATION_EXPIRES_AFTER: 3 | |
WCRS_REGISTRATION_RENEWAL_WINDOW: 3 | |
WCRS_REGISTRATION_GRACE_WINDOW: 5 | |
WCRS_RENEWAL_CHARGE: 10500 | |
WCRS_NEW_REGISTRATION_CHARGE: 15400 | |
WCRS_TYPE_CHANGE_CHARGE: 4000 | |
WCRS_CARD_CHARGE: 500 | |
WCRS_USE_AIRBRAKE: true | |
WCRS_MOCK_ENABLED: true | |
# Just used to make the tests pass | |
WCRS_WORLDPAY_ECOM_USERNAME: foo | |
WCRS_WORLDPAY_ECOM_PASSWORD: foo | |
WCRS_USE_XVFB_FOR_WICKEDPDF: true | |
ENV_VARIABLE_TEST_FEATURE: true | |
WCRS_GOVPAY_CALLBACK_WEBHOOK_SIGNING_SECRET: foo | |
WCRS_GOVPAY_BACK_OFFICE_CALLBACK_WEBHOOK_SIGNING_SECRET: foo2 | |
steps: | |
# Downloads a copy of the code in your repository before running CI tests | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of sonarcloud analysis | |
# Install various other dependencies | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install xvfb -y | |
sudo apt-get install wkhtmltopdf -y | |
sudo apt-get install -qq python python3-pip | |
sudo pip3 install mtools[mlaunch] | |
# We don't have to specify the ruby version, or grab it from .ruby-verion. This action supports reading the | |
# version from .ruby-version itself | |
- name: Install Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
- name: Set up databases | |
run: | | |
mlaunch --replicaset --name wcrepl --auth --username mongoAdmin --password password1234 | |
mongo "mongodb://mongoAdmin:password1234@localhost:27017,localhost:27018,localhost:27019/waste-carriers-test?authSource=admin&replicaSet=wcrepl" --eval 'db.createUser({user:"mongoUser", pwd:"password1234", roles:["readWrite", "dbAdmin", "userAdmin"]})' | |
mongo "mongodb://mongoAdmin:password1234@localhost:27017,localhost:27018,localhost:27019/waste-carriers-users-test?authSource=admin&replicaSet=wcrepl" --eval 'db.createUser({user:"mongoUser", pwd:"password1234", roles:["readWrite", "dbAdmin", "userAdmin"]})' | |
# Run linting first. No point running the tests if there is a linting issue | |
- name: Run lint check | |
run: | | |
bundle exec rubocop --format progress --format json --out rubocop-result.json | |
# This includes an extra run step. The sonarcloud analysis will be run in a docker container with the current | |
# folder mounted as `/github/workspace`. The problem is when the coverage.json file is generated it will | |
# reference the code in the current folder. So to enable sonarcloud to matchup code coverage with the files we use | |
# sed to update the references in coverage.json | |
# https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/6 | |
- name: Run unit tests | |
run: | | |
bundle exec rails test | |
bundle exec rspec | |
sed -i 's/\/home\/runner\/work\/waste-carriers-engine\/waste-carriers-engine\//\/github\/workspace\//g' coverage/coverage.json | |
- name: Analyze with SonarCloud | |
uses: sonarsource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This is provided automatically by GitHub | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # This needs to be set in your repo; settings -> secrets |