trigger CI #2322
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: Deploy | |
| on: | |
| push: | |
| branches: [master] | |
| env: | |
| LANG: C.UTF-8 | |
| LD_LIBRARY_PATH: '/usr/local/lib:$LD_LIBRARY_PATH' | |
| GHC_VERSION: 9.12.2 | |
| jobs: | |
| # Build frontend once and share via artifacts | |
| frontend: | |
| name: Build Frontend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| cache-dependency-path: | | |
| package-lock.json | |
| web-components/package-lock.json | |
| - name: Build frontend assets | |
| run: | | |
| mkdir -p static/public/assets/css | |
| mkdir -p static/public/assets/web-components/dist/js | |
| mkdir -p static/public/assets/web-components/dist/css | |
| npm ci | |
| npx tailwindcss -i ./static/public/assets/css/tailwind.css -o ./static/public/assets/css/tailwind.min.css --minify | |
| cd web-components | |
| npm ci | |
| NODE_ENV=production npx vite build --mode production --sourcemap false | |
| - name: Upload frontend artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: frontend-assets | |
| path: | | |
| static/public/assets/css/tailwind.min.css | |
| static/public/assets/web-components/dist | |
| retention-days: 1 | |
| test: | |
| name: Test ${{ matrix.test }} | |
| needs: frontend | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: timescale/timescaledb-ha:pg16-all | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: monoscope | |
| options: >- | |
| --health-cmd="pg_isready -U postgres" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| ports: | |
| - 5432:5432 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| test: [doctests, unit-tests, integration-tests] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Free Disk Space | |
| run: | | |
| echo "Disk space before cleanup:" | |
| df -h | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL | |
| sudo docker image prune --all --force | |
| echo "Disk space after cleanup:" | |
| df -h | |
| - name: Install system dependencies | |
| uses: awalsh128/cache-apt-pkgs-action@latest | |
| with: | |
| packages: libssl-dev librdkafka-dev libgrpc-dev protobuf-compiler libsnappy-dev libpq-dev libldap2-dev libsasl2-dev liblz4-dev libzstd-dev pkg-config | |
| version: 1.0 | |
| - name: Set OpenSSL environment variables | |
| run: | | |
| echo "OPENSSL_INCLUDE_DIR=$(pkg-config --variable=includedir openssl)" >> $GITHUB_ENV | |
| echo "OPENSSL_LIB_DIR=$(pkg-config --variable=libdir openssl)" >> $GITHUB_ENV | |
| - uses: haskell-actions/setup@v2 | |
| with: | |
| ghc-version: ${{ env.GHC_VERSION }} | |
| cabal-version: 'latest' | |
| # Shared cache across all test matrix jobs | |
| - name: Cache Haskell dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cabal/store | |
| dist-newstyle | |
| key: ${{ runner.os }}-cabal-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}-${{ hashFiles('src/**', 'app/**', 'test/**') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cabal-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}- | |
| ${{ runner.os }}-cabal- | |
| - name: Download frontend artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: frontend-assets | |
| path: static/public/assets | |
| - name: Setup static directories | |
| run: | | |
| mkdir -p static/public/assets/css | |
| mkdir -p static/public/assets/web-components/dist/js | |
| mkdir -p static/public/assets/web-components/dist/css | |
| - name: Update cabal index | |
| run: cabal update | |
| - name: Configure project | |
| run: cabal configure --enable-tests --enable-benchmarks --ghc-options="-O0 +RTS -A64m -n2m -RTS" | |
| - name: Build dependencies | |
| run: cabal build --only-dependencies all -j | |
| - name: Build ${{ matrix.test }} | |
| run: cabal build ${{ matrix.test }} -j | |
| - name: Run ${{ matrix.test }} | |
| env: | |
| USE_EXTERNAL_DB: true | |
| LOG_LEVEL: ${{ matrix.test == 'integration-tests' && 'warn' || '' }} | |
| TWILIO_ACCOUNT_SID: ${{ vars.TWILIO_ACCOUNT_SID }} | |
| DISCORD_CLIENT_ID: "1328384474395967631" | |
| run: | | |
| echo "::group::Running ${{ matrix.test }}" | |
| cabal test ${{ matrix.test }} --ghc-options="-O0" --test-show-details=direct | |
| echo "::endgroup::" | |
| build-and-deploy: | |
| name: Build and Deploy Docker Image | |
| runs-on: self-hosted | |
| if: always() | |
| permissions: | |
| contents: 'read' | |
| id-token: 'write' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GH_TOKEN }} | |
| - name: Build and push Docker Image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }} | |
| ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest | |
| cache-from: | | |
| type=gha | |
| type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:buildcache | |
| cache-to: | | |
| type=gha,mode=max | |
| type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:buildcache,mode=max | |
| platforms: linux/amd64 | |
| provenance: false | |
| build-args: | | |
| BUILDKIT_INLINE_CACHE=1 | |
| - name: Deploy Image to CapRrover | |
| uses: caprover/deploy-from-github@v1.2.0 | |
| with: | |
| server: '${{ secrets.CAPTAINROVER_SERVER }}' | |
| app: '${{ secrets.CAPTAINROVER_APP_NAME }}' | |
| token: '${{ secrets.CAPTAINROVER_APP_TOKEN }}' | |
| image: 'ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}' |