|
| 1 | +name: Missing FK Indexes |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: ["main", "development"] |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: missing-kf-indexes-${{ github.ref_name }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + generateMatrix: |
| 14 | + name: "Generate matrix from cabal" |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 18 | + steps: |
| 19 | + - name: Extract the tested GHC versions |
| 20 | + id: set-matrix |
| 21 | + |
| 22 | + with: |
| 23 | + cabal-file: flora.cabal |
| 24 | + ubuntu-version: "latest" |
| 25 | + version: 0.1.7.1 |
| 26 | + |
| 27 | + index-check: |
| 28 | + needs: generateMatrix |
| 29 | + runs-on: ${{ matrix.os }} |
| 30 | + strategy: |
| 31 | + matrix: ${{ fromJSON(needs.generateMatrix.outputs.matrix) }} |
| 32 | + # Service containers to run with `container-job` |
| 33 | + services: |
| 34 | + # Label used to access the service container |
| 35 | + postgres: |
| 36 | + # Docker Hub image |
| 37 | + image: postgres |
| 38 | + # Provide the password for postgres |
| 39 | + env: |
| 40 | + POSTGRES_PASSWORD: postgres |
| 41 | + # Set health checks to wait until postgres has started |
| 42 | + options: >- |
| 43 | + --health-cmd pg_isready |
| 44 | + --health-interval 10s |
| 45 | + --health-timeout 5s |
| 46 | + --health-retries 5 |
| 47 | + ports: |
| 48 | + - 5432:5432 |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Set up Haskell |
| 53 | + id: setup-haskell |
| 54 | + uses: haskell-actions/setup@v2 |
| 55 | + with: |
| 56 | + ghc-version: "${{ matrix.ghc }}" |
| 57 | + cabal-version: "latest" |
| 58 | + |
| 59 | + - name: Configure environment |
| 60 | + run: | |
| 61 | + ./.github/workflows/setup.sh |
| 62 | + echo "/usr/lib/postgresql/14/bin/" >> $GITHUB_PATH |
| 63 | + echo "$HOME/.ghcup/bin" >> $GITHUB_PATH |
| 64 | + echo "$HOME/.cabal/bin" >> $GITHUB_PATH |
| 65 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 66 | + echo "$HOME/node_modules/.bin" >> $GITHUB_PATH |
| 67 | + sudo apt install libsodium-dev |
| 68 | + source ./environment.ci.sh |
| 69 | + touch ~/.pgpass |
| 70 | + chmod 0600 ~/.pgpass |
| 71 | + echo "${FLORA_DB_HOST}:${FLORA_DB_PORT}:${FLORA_DB_DATABASE}:${FLORA_DB_USER}:${FLORA_DB_PASSWORD}" > .pgpass |
| 72 | + cat ~/.pgpass |
| 73 | + cabal update |
| 74 | +
|
| 75 | + - name: Cache |
| 76 | + |
| 77 | + with: |
| 78 | + path: ${{ steps.setup-haskell.outputs.cabal-store }} |
| 79 | + key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{ hashFiles('./.plan.json') }} |
| 80 | + restore-keys: ${{ runner.os }}-ghc-${{ matrix.ghc }}- |
| 81 | + |
| 82 | + |
| 83 | + - name: Migrate |
| 84 | + run: | |
| 85 | + cabal install postgresql-migration |
| 86 | + set -x |
| 87 | + source ./environment.ci.sh |
| 88 | + createdb -h "${FLORA_DB_HOST}" -p "${FLORA_DB_PORT}" -U "${FLORA_DB_USER}" -w "${FLORA_DB_DATABASE}" |
| 89 | + migrate init "${FLORA_DB_CONNSTRING}" |
| 90 | + migrate migrate "${FLORA_DB_CONNSTRING}" migrations |
| 91 | + env: |
| 92 | + PGPASSWORD: "postgres" |
| 93 | + |
| 94 | + - name: Check |
| 95 | + run: | |
| 96 | + source ./environment.ci.sh |
| 97 | + .github/workflows/check-missing-fk-indexes.sh |
0 commit comments