github.com/crowdsecurity/crowdsec@v1.6.1/.github/workflows/bats-postgres.yml (about)

     1  name: (sub) Bats / Postgres
     2  
     3  on:
     4    workflow_call:
     5  
     6  jobs:
     7    build:
     8      name: "Functional tests"
     9      runs-on: ubuntu-latest
    10      timeout-minutes: 30
    11      services:
    12        database:
    13          image: postgres:16
    14          env:
    15            POSTGRES_PASSWORD: "secret"
    16          ports:
    17            - 5432:5432
    18          options: >-
    19            --health-cmd pg_isready -u postgres
    20            --health-interval 10s
    21            --health-timeout 5s
    22            --health-retries 5
    23  
    24      steps:
    25  
    26      - name: "Install pg_dump v16"
    27        # we can remove this when it's released on ubuntu-latest
    28        run: |
    29            sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
    30            wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
    31            sudo apt update
    32            sudo apt -qq -y -o=Dpkg::Use-Pty=0 install postgresql-client-16
    33  
    34      - name: "Force machineid"
    35        run: |
    36            sudo chmod +w /etc/machine-id
    37            echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
    38  
    39      - name: "Check out CrowdSec repository"
    40        uses: actions/checkout@v4
    41        with:
    42          fetch-depth: 0
    43          submodules: true
    44  
    45      - name: "Set up Go"
    46        uses: actions/setup-go@v5
    47        with:
    48          go-version: "1.21.9"
    49  
    50      - name: "Install bats dependencies"
    51        env:
    52          GOBIN: /usr/local/bin
    53        run: |
    54          sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq libre2-dev
    55  
    56      - name: "Build crowdsec and fixture (DB_BACKEND: pgx)"
    57        run: |
    58          make clean bats-build bats-fixture BUILD_STATIC=1
    59        env:
    60          DB_BACKEND: pgx
    61          PGHOST: 127.0.0.1
    62          PGPORT: 5432
    63          PGPASSWORD: "secret"
    64          PGUSER: postgres
    65  
    66      - name: "Run tests (DB_BACKEND: pgx)"
    67        run: ./test/run-tests ./test/bats --formatter $(pwd)/test/lib/color-formatter
    68        env:
    69          DB_BACKEND: pgx
    70          PGHOST: 127.0.0.1
    71          PGPORT: 5432
    72          PGPASSWORD: "secret"
    73          PGUSER: postgres
    74  
    75      - name: "Show stack traces"
    76        run: for file in $(find /tmp/crowdsec-crash.*.txt); do echo ">>>>> $file"; cat $file; echo; done
    77        if: ${{ always() }}
    78  
    79      - name: "Show crowdsec logs"
    80        run: for file in $(find ./test/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
    81        if: ${{ always() }}
    82  
    83      - name: "Show database logs"
    84        run: docker logs "${{ job.services.database.id }}"
    85        if: ${{ always() }}