github.com/benz9527/xboot@v0.0.0-20240504061247-c23f15593274/.github/workflows/go.yml (about)

     1  # This workflow will build a golang project
     2  # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
     3  
     4  name: xboot-ci-test
     5  
     6  on:
     7    push:
     8      branches: ["master"]
     9    pull_request:
    10      branches: ["master"]
    11  
    12  jobs:
    13    convTest:
    14      name: Test with Coverage
    15      runs-on: ubuntu-latest
    16      strategy:
    17        matrix:
    18          go-version: ["1.22.x"]
    19          redis-version: ["7-alpine", "6-alpine"]
    20      services:
    21        redis:
    22          image: redis:${{ matrix.redis-version }}
    23          ports:
    24            - 6379:6379
    25      steps:
    26        - name: Set up Go env
    27          uses: actions/setup-go@v4
    28          with:
    29            go-version: ${{ matrix.go-version }}
    30            check-latest: true
    31          id: xboot
    32  
    33        - name: Check out code into the Go module directory
    34          uses: actions/checkout@v3
    35  
    36        - name: Install dependencies
    37          run: go mod download
    38  
    39        - name: Unit Test
    40          run: |
    41            export DISABLE_TEST_DEBUG_LOG=true
    42            export REDIS_DLOCK_ADDR=127.0.0.1:6379
    43            export REDIS_DLOCK_PWD=""
    44            go test -timeout=1800s -covermode atomic -coverprofile=./cover.out ./...
    45  
    46        - uses: codecov/codecov-action@v4
    47          with:
    48            fail_ci_if_error: true
    49            files: ./cover.out
    50            name: codecov-umbrella
    51            verbose: false
    52          env:
    53            CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
    54  
    55    raceTest:
    56      name: Test with race detector
    57      runs-on: ubuntu-latest
    58      strategy:
    59        matrix:
    60          go-version: ["1.22.x"]
    61          redis-version: ["7-alpine", "6-alpine"]
    62      services:
    63        redis:
    64          image: redis:${{ matrix.redis-version }}
    65          ports:
    66            - 6379:6379
    67      steps:
    68        - name: Set up Go env
    69          uses: actions/setup-go@v4
    70          with:
    71            go-version: ${{ matrix.go-version }}
    72            check-latest: true
    73          id: xboot
    74  
    75        - name: Check out code into the Go module directory
    76          uses: actions/checkout@v3
    77  
    78        - name: Install dependencies
    79          run: go mod download
    80  
    81        - name: Unit Test
    82          run: |
    83            export DISABLE_TEST_DEBUG_LOG=true
    84            export REDIS_DLOCK_ADDR=127.0.0.1:6379
    85            export REDIS_DLOCK_PWD=""
    86            go test -timeout=1800s -race -run ^Test.*DataRace.*$ ./dlock
    87            go test -timeout=1800s -race -run ^Test.*DataRace.*$ ./lib/id 
    88            go test -timeout=1800s -race -run ^Test.*DataRace.*$ ./lib/list
    89            go test -timeout=1800s -race -run ^Test.*DataRace.*$ ./lib/queue
    90            go test -timeout=1800s -race -run ^Test.*DataRace.*$ ./lib/kv
    91            go test -timeout=1800s -race -run ^Test.*DataRace.*$ ./lib/tree
    92            go test -timeout=1800s -race -run ^Test.*DataRace.*$ ./xlog
    93            go test -timeout=1800s -race -run ^Test.*DataRace.*$ ./timer
    94  
    95    benchTest:
    96      name: Benchmark Test
    97      runs-on: ubuntu-latest
    98      strategy:
    99        matrix:
   100          go-version: ["1.22.x"]
   101      steps:
   102        - name: Set up Go env
   103          uses: actions/setup-go@v4
   104          with:
   105            go-version: ${{ matrix.go-version }}
   106            check-latest: true
   107          id: xboot
   108  
   109        - name: Check out code into the Go module directory
   110          uses: actions/checkout@v3
   111  
   112        - name: Install dependencies
   113          run: go mod download
   114  
   115        - name: Unit Test
   116          run: |
   117            export DISABLE_TEST_DEBUG_LOG=true
   118            go test -benchmem -bench ^Benchmark.*$ ./lib/list
   119            go test -benchmem -bench ^Benchmark.*$ ./lib/kv
   120            go test -benchmem -bench ^Benchmark.*$ ./lib/queue
   121            go test -benchmem -bench ^Benchmark.*$ ./lib/tree
   122            go test -benchmem -bench ^Benchmark.*$ ./timer
   123            go test -benchmem -bench ^Benchmark.*$ ./xlog