Smail/.github/workflows/unitTest.yml
2026-05-23 00:07:49 +08:00

70 lines
1.7 KiB
YAML

name: PR - Docker unit test
on:
pull_request:
branches:
- master
types: [opened, reopened, synchronize, edited]
# Please, always create a pull request instead of push to master.
permissions:
contents: read
pull-requests: write
concurrency:
group: docker-test-${{ github.ref_name }}
cancel-in-progress: true
jobs:
test:
name: Docker tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql
env:
MYSQL_DATABASE: pmail
MYSQL_ROOT_PASSWORD: githubTest
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres
env:
POSTGRESQL_PASSWORD: githubTest
container:
image: golang
env:
REPOSITORY: ${{ github.repository }}
TRIGGERING_ACTOR: ${{ github.triggering_actor }}
SOURCE_BRANCH: ${{ github.ref_name }}
COMMIT: ${{ github.workflow_sha }}
EVENT: ${{ github.event_name}}
steps:
- name: Setup Node.js environment
run: apt update && apt install -y nodejs npm
- name: Checkout
uses: actions/checkout@v4
- name: Pull Request Labeler
if: ${{ failure() }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr edit ${{ github.event.pull_request.number }} --add-label "Auto: Test Failed"
- name: Install Dependencies
run: npm install --global yarn
- name: FE build
run: make build_fe
- name: Run Test Mysql
run: make test_mysql
- name: Run Test
run: make test
# - name: Run postgres
# run: make test_postgres