mirror of
https://github.com/mattermost/mattermost.git
synced 2026-04-11 20:17:04 -04:00
105 lines
5.3 KiB
YAML
105 lines
5.3 KiB
YAML
name: Server Test Template
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
name:
|
|
required: true
|
|
type: string
|
|
datasource:
|
|
required: true
|
|
type: string
|
|
drivername:
|
|
required: true
|
|
type: string
|
|
logsartifact:
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
test:
|
|
name: ${{ inputs.name }}
|
|
runs-on: ubuntu-22.04
|
|
env:
|
|
COMPOSE_PROJECT_NAME: ghactions
|
|
steps:
|
|
- name: Checkout mattermost project
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
|
- name: Calculate Golang Version
|
|
id: go
|
|
working-directory: ./server
|
|
run: echo GO_VERSION=$(cat .go-version) >> "${GITHUB_OUTPUT}"
|
|
- name: Setup Go
|
|
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
|
|
with:
|
|
go-version: ${{ steps.go.outputs.GO_VERSION }}
|
|
cache-dependency-path: server/go.sum
|
|
- name: Run docker compose
|
|
run: |
|
|
cd server/build
|
|
docker compose --ansi never run --rm start_dependencies
|
|
cat ../tests/test-data.ldif | docker compose --ansi never exec -T openldap bash -c 'ldapadd -x -D "cn=admin,dc=mm,dc=test,dc=com" -w mostest';
|
|
docker compose --ansi never exec -T minio sh -c 'mkdir -p /data/mattermost-test';
|
|
docker compose --ansi never ps
|
|
- name: Run Tests
|
|
env:
|
|
BUILD_IMAGE: mattermost/mattermost-build-server:${{ steps.go.outputs.GO_VERSION }}
|
|
run: |
|
|
if [[ ${{ github.ref_name }} == 'master' ]]; then
|
|
export RACE_MODE="-race"
|
|
fi
|
|
docker run --net ghactions_mm-test \
|
|
--ulimit nofile=8096:8096 \
|
|
--env-file=server/build/dotenv/test.env \
|
|
--env MM_SQLSETTINGS_DRIVERNAME="${{ inputs.drivername }}" \
|
|
--env MM_SQLSETTINGS_DATASOURCE="${{ inputs.datasource }}" \
|
|
--env TEST_DATABASE_MYSQL_DSN="${{ inputs.datasource }}" \
|
|
--env TEST_DATABASE_POSTGRESQL_DSN="${{ inputs.datasource }}" \
|
|
-v $(go env GOCACHE):/go/cache \
|
|
-e GOCACHE=/go/cache \
|
|
-v $PWD:/mattermost \
|
|
-w /mattermost/server \
|
|
$BUILD_IMAGE \
|
|
make test-server$RACE_MODE BUILD_NUMBER=$GITHUB_HEAD_REF-$GITHUB_RUN_ID
|
|
- name: Stop docker compose
|
|
run: |
|
|
cd server/build
|
|
docker compose --ansi never stop
|
|
- name: Archive logs
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
|
|
with:
|
|
name: ${{ inputs.logsartifact }}
|
|
path: |
|
|
server/gotestsum.json
|
|
server/report.xml
|
|
- name: Publish test report
|
|
id: report
|
|
uses: mikepenz/action-junit-report@dfc44cebdda1e40b1e3c3b244a84dc303b952fb0 # v3.7.7 + count retries + check urls from https://github.com/lieut-data/action-junit-report
|
|
if: success() || failure() # always run even if the previous step fails
|
|
with:
|
|
report_paths: server/report.xml
|
|
check_name: ${{ inputs.name }} (Results)
|
|
require_tests: true
|
|
- name: Report retried tests via webhook (master || release-*)
|
|
if: ${{ steps.report.outputs.retried > 0 && (github.ref_name == 'master' || startsWith(github.ref_name, 'release-')) }}
|
|
uses: mattermost/action-mattermost-notify@b7d118e440bf2749cd18a4a8c88e7092e696257a # v2.0.0
|
|
with:
|
|
MATTERMOST_WEBHOOK_URL: ${{ secrets.MM_COMMUNITY_DEVELOPERS_INCOMING_WEBHOOK_FROM_GH_ACTIONS }}
|
|
TEXT: |-
|
|
#### ⚠️ One or more flaky tests detected ⚠️
|
|
* Failing job: [github.com/mattermost/mattermost:${{ inputs.name }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
|
|
* Ideally, this would have been caught in a pull request, but now a volunteer is required. If you're willing to help, submit a separate pull request to skip the flaky tests (e.g. [23360](https://github.com/mattermost/mattermost/pull/23360)) and file JIRA ticket (e.g. [MM-52743](https://mattermost.atlassian.net/browse/MM-52743)) for later investigation.
|
|
* Finally, reply to this message with a link to the created JIRA ticket.
|
|
- name: Report retried tests (pull request)
|
|
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
|
|
if: ${{ steps.report.outputs.retried > 0 && !(github.ref_name == 'master' || startsWith(github.ref_name, 'release-')) }}
|
|
with:
|
|
script: |
|
|
const body = `#### ⚠️ One or more flaky tests detected ⚠️\n* Failing job: [github.com/mattermost/mattermost:${{ inputs.name }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})\n* Double check your code to ensure you haven't introduced a flaky test.\n* If this seems to be unrelated to your changes, submit a separate pull request to skip the flaky tests (e.g. [23360](https://github.com/mattermost/mattermost/pull/23360)) and file JIRA ticket (e.g. [MM-52743](https://mattermost.atlassian.net/browse/MM-52743)) for later investigation.`
|
|
|
|
await github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: body
|
|
})
|