Atlas and atlas_rb update #655
This file contains hidden or 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: Build-Test | |
| on: | |
| push: | |
| branches: [ "develop" ] | |
| pull_request: | |
| branches: [ "develop" ] | |
| jobs: | |
| build_and_test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Make env file | |
| run: | | |
| cp .env.example .env | |
| # The Atlas image both atlas services run, from the one file that pins it. | |
| # .env.example deliberately carries no version: it is documentation, and a | |
| # test run must not change because someone edited a comment in it. | |
| echo "ATLAS=$(cat .atlas_version)" >> .env | |
| echo "ATLAS_RAILS_MASTER_KEY=${{ secrets.ATLAS_RAILS_MASTER_KEY }}" >> .env | |
| # Cerberus's own master key, so the web container can decrypt | |
| # credentials and sign Atlas assertions (config/master.key is | |
| # gitignored, so it's absent from the CI image). See docker-compose.ci.yml. | |
| echo "RAILS_MASTER_KEY=${{ secrets.RAILS_MASTER_KEY }}" >> .env | |
| - name: Dotenv Action | |
| uses: falti/dotenv-action@v1.1.4 | |
| - name: Github Action cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/caches | |
| key: ${{ runner.os }}-${{ hashFiles('Gemfile.lock') }} | |
| - name: Load Docker image | |
| run: | | |
| set +o pipefail | |
| docker load -i ~/caches/cerberus.tar | true | |
| - name: Build the Docker image | |
| run: docker build --cache-from=nakatomi/cerberus_web:latest . --file Dockerfile --tag nakatomi/cerberus_web:latest --tag nakatomi/cerberus_web:$(cat .version) | |
| - name: Save Docker image | |
| run: | | |
| mkdir -p ~/caches | |
| docker save -o ~/caches/cerberus.tar nakatomi/cerberus_web | |
| - name: Setup dockerize | |
| uses: zcong1993/setup-dockerize@v2.0.0 | |
| - name: Start server | |
| run: | | |
| set -x | |
| docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d | |
| # - name: Create database and migrate | |
| # run: | | |
| # docker compose exec -T web bundle exec rake db:migrate | |
| - name: Wait until available | |
| run: dockerize -wait http://localhost:3000 -timeout 1m | |
| - name: Run tests | |
| run: | | |
| docker compose exec -T web bundle exec rake | |
| - name: Retrieve coverage results | |
| run: docker compose cp web:/home/cerberus/web/coverage ./coverage | |
| - name: Upload coverage files | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage | |
| - name: Extract coverage percentage | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/develop' | |
| id: coverage | |
| run: | | |
| pct=$(jq -r '.result.line' coverage/.last_run.json) | |
| echo "pct=$pct" >> "$GITHUB_OUTPUT" | |
| - name: Update coverage badge gist | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/develop' | |
| uses: schneegans/dynamic-badges-action@v1.7.0 | |
| with: | |
| auth: ${{ secrets.GIST_SECRET }} | |
| gistID: ${{ vars.COVERAGE_GIST_ID }} | |
| filename: cerberus-coverage.json | |
| label: coverage | |
| message: ${{ steps.coverage.outputs.pct }}% | |
| valColorRange: ${{ steps.coverage.outputs.pct }} | |
| minColorRange: 50 | |
| maxColorRange: 90 |