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

     1  name: (sub) Bats / MySQL
     2  
     3  on:
     4    workflow_call:
     5      inputs:
     6        database_image:
     7          required: true
     8          type: string
     9  
    10  jobs:
    11    build:
    12      name: "Functional tests"
    13      runs-on: ubuntu-latest
    14      timeout-minutes: 30
    15      services:
    16        database:
    17          image: ${{ inputs.database_image }}
    18          env:
    19            MYSQL_ROOT_PASSWORD: "secret"
    20          ports:
    21            - 3306:3306
    22  
    23      steps:
    24  
    25      - name: "Force machineid"
    26        run: |
    27            sudo chmod +w /etc/machine-id
    28            echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
    29  
    30      - name: "Check out CrowdSec repository"
    31        uses: actions/checkout@v4
    32        with:
    33          fetch-depth: 0
    34          submodules: true
    35  
    36      - name: "Set up Go"
    37        uses: actions/setup-go@v5
    38        with:
    39          go-version: "1.21.9"
    40  
    41      - name: "Install bats dependencies"
    42        env:
    43          GOBIN: /usr/local/bin
    44        run: |
    45          sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq libre2-dev
    46  
    47      - name: "Build crowdsec and fixture"
    48        run: |
    49          make clean bats-build bats-fixture BUILD_STATIC=1
    50        env:
    51          DB_BACKEND: mysql
    52          MYSQL_HOST: 127.0.0.1
    53          MYSQL_PORT: 3306
    54          MYSQL_PASSWORD: "secret"
    55          MYSQL_USER: root
    56  
    57      - name: "Run tests"
    58        run: ./test/run-tests ./test/bats --formatter $(pwd)/test/lib/color-formatter
    59        env:
    60          DB_BACKEND: mysql
    61          MYSQL_HOST: 127.0.0.1
    62          MYSQL_PORT: 3306
    63          MYSQL_PASSWORD: "secret"
    64          MYSQL_USER: root
    65  
    66      #
    67      # In case you need to inspect the database status after the failure of a given test
    68      #
    69      # - name: "Run specified tests"
    70      #   run: ./test/run-tests test/bats/<filename>.bats -f "<test name>"
    71  
    72      - name: Show database dump
    73        run: ./test/instance-db dump /dev/fd/1
    74        env:
    75          DB_BACKEND: mysql
    76          MYSQL_HOST: 127.0.0.1
    77          MYSQL_PORT: 3306
    78          MYSQL_PASSWORD: "secret"
    79          MYSQL_USER: root
    80        if: ${{ always() }}
    81  
    82      - name: "Show stack traces"
    83        run: for file in $(find /tmp/crowdsec-crash.*.txt); do echo ">>>>> $file"; cat $file; echo; done
    84        if: ${{ always() }}
    85  
    86      - name: "Show crowdsec logs"
    87        run: for file in $(find ./test/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
    88        if: ${{ always() }}
    89  
    90      - name: "Show database logs"
    91        run: docker logs "${{ job.services.database.id }}"
    92        if: ${{ always() }}