update #3
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: Console CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: [ main ] | |
| defaults: | |
| run: | |
| working-directory: services/console | |
| jobs: | |
| console_changes: | |
| name: Detect Console CI changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| relevant: ${{ steps.filter.outputs.relevant }} | |
| defaults: | |
| run: | |
| working-directory: . | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - id: filter | |
| name: Detect changed paths | |
| run: | | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| base="${{ github.event.pull_request.base.sha }}" | |
| changed_files="$(git diff --name-only "${base}...HEAD")" | |
| elif [[ "${{ github.event_name }}" == "push" ]]; then | |
| changed_files="$(git diff --name-only "${{ github.event.before }}...HEAD")" | |
| else | |
| git fetch --no-tags --depth=1 origin main | |
| changed_files="$(git diff --name-only origin/main...HEAD)" | |
| fi | |
| if printf '%s\n' "${changed_files}" | grep -Eq '^(services/console/|\.github/workflows/console-ci\.yml$)'; then | |
| echo "relevant=true" >>"${GITHUB_OUTPUT}" | |
| else | |
| echo "relevant=false" >>"${GITHUB_OUTPUT}" | |
| fi | |
| scan_ruby: | |
| runs-on: depot-ubuntu-24.04-16 | |
| needs: console_changes | |
| if: needs.console_changes.outputs.relevant == 'true' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@12fd324f1d0b43274fdc8130f6980590a667c455 # v1.312.0 | |
| with: | |
| working-directory: services/console | |
| bundler-cache: true | |
| - name: Scan for common Rails security vulnerabilities using static analysis | |
| run: bin/brakeman --no-pager | |
| - name: Scan for known security vulnerabilities in gems used | |
| run: bin/bundler-audit | |
| scan_js: | |
| runs-on: depot-ubuntu-24.04-16 | |
| needs: console_changes | |
| if: needs.console_changes.outputs.relevant == 'true' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@12fd324f1d0b43274fdc8130f6980590a667c455 # v1.312.0 | |
| with: | |
| working-directory: services/console | |
| bundler-cache: true | |
| - name: Scan for security vulnerabilities in JavaScript dependencies | |
| run: bin/importmap audit | |
| lint: | |
| runs-on: depot-ubuntu-24.04-16 | |
| needs: console_changes | |
| if: needs.console_changes.outputs.relevant == 'true' | |
| env: | |
| RUBOCOP_CACHE_ROOT: ${{ github.workspace }}/services/console/tmp/rubocop | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@12fd324f1d0b43274fdc8130f6980590a667c455 # v1.312.0 | |
| with: | |
| working-directory: services/console | |
| bundler-cache: true | |
| - name: Prepare RuboCop cache | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| env: | |
| DEPENDENCIES_HASH: ${{ hashFiles('services/console/.ruby-version', 'services/console/**/.rubocop.yml', 'services/console/**/.rubocop_todo.yml', 'services/console/Gemfile.lock') }} | |
| with: | |
| path: ${{ env.RUBOCOP_CACHE_ROOT }} | |
| key: rubocop-${{ runner.os }}-${{ env.DEPENDENCIES_HASH }}-${{ github.ref_name == github.event.repository.default_branch && github.run_id || 'default' }} | |
| restore-keys: | | |
| rubocop-${{ runner.os }}-${{ env.DEPENDENCIES_HASH }}- | |
| - name: Lint code for consistent style | |
| run: bin/rubocop -f github | |
| test: | |
| runs-on: depot-ubuntu-24.04-16 | |
| needs: console_changes | |
| if: needs.console_changes.outputs.relevant == 'true' | |
| services: | |
| postgres: | |
| image: postgres:17 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| ports: | |
| - 5432:5432 | |
| options: --health-cmd="pg_isready -U postgres" --health-interval=10s --health-timeout=5s --health-retries=5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Install packages | |
| run: sudo apt-get update && sudo apt-get install --no-install-recommends -y libvips libpq-dev | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@12fd324f1d0b43274fdc8130f6980590a667c455 # v1.312.0 | |
| with: | |
| working-directory: services/console | |
| bundler-cache: true | |
| - name: Run tests | |
| env: | |
| RAILS_ENV: test | |
| IRON_CONTROL_DB_HOST: localhost | |
| IRON_CONTROL_DB_PORT: 5432 | |
| IRON_CONTROL_DB_USERNAME: postgres | |
| IRON_CONTROL_DB_PASSWORD: postgres | |
| # RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} | |
| run: bin/rails db:test:prepare test | |
| console-ci-success: | |
| name: Console CI success | |
| runs-on: ubuntu-latest | |
| if: always() | |
| needs: | |
| - console_changes | |
| - scan_ruby | |
| - scan_js | |
| - lint | |
| - test | |
| timeout-minutes: 30 | |
| defaults: | |
| run: | |
| working-directory: . | |
| steps: | |
| - name: Decide whether the needed jobs succeeded or failed | |
| uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # release/v1 | |
| with: | |
| allowed-skips: scan_ruby, scan_js, lint, test | |
| jobs: ${{ toJSON(needs) }} |