From 6cd430528c00892d0115a6523c6780c0bced9784 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 5 Mar 2026 16:56:45 -0600 Subject: [PATCH] perf(ci): optimize pipeline for faster execution Optimizations: - Combined 5 separate cache steps into single unified cache (faster restoration) - Removed redundant PostgreSQL wait (service health checks already ensure ready) - Removed redundant deps.compile step (mix compile handles it) - Removed system deps caching (marginal benefit, adds overhead) - Faster postgres health checks (3s interval vs 5s) - Added --max-cases 24 for parallel test execution - Simplified deps.get to --only test (don't need dev/prod deps) Expected speedup: 20-30% faster cold runs, 40-50% faster warm runs --- .forgejo/workflows/build.yaml | 70 +++++++---------------------------- 1 file changed, 14 insertions(+), 56 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index afb67120..bc60e9f7 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -19,6 +19,7 @@ jobs: runs-on: ubuntu-22.04 env: DATABASE_URL: postgresql://postgres:postgres@postgres:5432/towerops_test + ERL_AFLAGS: "-kernel shell_history enabled" services: postgres: image: timescale/timescaledb:latest-pg17 @@ -28,8 +29,8 @@ jobs: POSTGRES_DB: towerops_test options: >- --health-cmd pg_isready - --health-interval 5s - --health-timeout 3s + --health-interval 3s + --health-timeout 2s --health-retries 10 steps: @@ -43,75 +44,32 @@ jobs: elixir-version: '1.19.5' version-type: strict - - name: Cache system dependencies - uses: actions/cache@v4 - id: system-deps-cache - with: - path: /var/cache/apt - key: ${{ runner.os }}-apt-${{ hashFiles('.forgejo/workflows/build.yaml') }} - restore-keys: ${{ runner.os }}-apt- - - - name: Install system dependencies - run: | - if [ "${{ steps.system-deps-cache.outputs.cache-hit }}" != "true" ]; then - sudo apt-get update - fi - sudo apt-get install -y --no-install-recommends libsnmp-dev snmp-mibs-downloader postgresql-client - - - name: Cache Hex packages + - name: Restore caches uses: actions/cache@v4 with: path: | ~/.hex ~/.mix - key: ${{ runner.os }}-hex-mix-elixir-1.19.5-otp-28.3 - restore-keys: ${{ runner.os }}-hex-mix- - - - name: Cache Mix dependencies - uses: actions/cache@v4 - with: - path: deps - key: ${{ runner.os }}-mix-deps-${{ hashFiles('**/mix.lock') }}-elixir-1.19.5-otp-28.3 - restore-keys: | - ${{ runner.os }}-mix-deps-${{ hashFiles('**/mix.lock') }}- - ${{ runner.os }}-mix-deps- - - - name: Cache Rust/Cargo build - uses: actions/cache@v4 - with: - path: | + deps + _build native/towerops_native/target ~/.cargo/registry ~/.cargo/git - key: ${{ runner.os }}-cargo-${{ hashFiles('native/towerops_native/Cargo.lock') }}-${{ hashFiles('native/towerops_native/src/**/*.rs') }} + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}-${{ hashFiles('lib/**/*.ex') }}-${{ hashFiles('native/**/*.rs') }}-elixir-1.19.5-otp-28.3 restore-keys: | - ${{ runner.os }}-cargo-${{ hashFiles('native/towerops_native/Cargo.lock') }}- - ${{ runner.os }}-cargo- + ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}- + ${{ runner.os }}-mix- - - name: Cache compiled build - uses: actions/cache@v4 - with: - path: _build - key: ${{ runner.os }}-mix-build-${{ hashFiles('**/mix.lock') }}-${{ hashFiles('lib/**/*.ex') }}-${{ hashFiles('native/**/*.rs') }}-elixir-1.19.5-otp-28.3 - restore-keys: | - ${{ runner.os }}-mix-build-${{ hashFiles('**/mix.lock') }}- - ${{ runner.os }}-mix-build- + - name: Install system dependencies + run: sudo apt-get install -y --no-install-recommends libsnmp-dev snmp-mibs-downloader postgresql-client - - name: Install dependencies - run: mix deps.get - - - name: Compile dependencies - run: mix deps.compile - - - name: Wait for PostgreSQL - run: | - timeout 30 bash -c 'until pg_isready -h postgres -p 5432 -U postgres; do sleep 1; done' - echo "PostgreSQL is ready!" + - name: Install Elixir dependencies + run: mix deps.get --only test - name: Compile and test run: | mix compile --warnings-as-errors - mix test --warnings-as-errors + mix test --warnings-as-errors --max-cases 24 build: runs-on: ubuntu-22.04