github.com/wangyougui/gf/v2@v2.6.5/.github/workflows/ci-main.yml (about)

     1  # The main codes build and unit testing running workflow.
     2  name: GoFrame Main CI
     3  
     4  
     5  on:
     6    push:
     7      branches:
     8      - master
     9      - develop
    10      - personal/**
    11      - feature/**
    12      - enhance/**
    13      - fix/**
    14  
    15    pull_request:
    16      branches:
    17      - master
    18      - develop
    19      - personal/**
    20      - feature/**
    21      - enhance/**
    22      - fix/**
    23  
    24  # This allows a subsequently queued workflow run to interrupt previous runs
    25  concurrency:
    26    group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
    27    cancel-in-progress: true
    28  
    29  env:
    30    TZ: "Asia/Shanghai"
    31  
    32  
    33  jobs:
    34    code-test:
    35      runs-on: ubuntu-latest
    36  
    37      # Service containers to run with `code-test`
    38      services:
    39        # Etcd service.
    40        # docker run -d --name etcd -p 2379:2379 -e ALLOW_NONE_AUTHENTICATION=yes loads/etcd:3.4.24
    41        etcd:
    42          image: loads/etcd:3.4.24
    43          env:
    44            ALLOW_NONE_AUTHENTICATION: yes
    45          ports:
    46            - 2379:2379
    47  
    48        # Redis backend server.
    49        redis:
    50          image  : loads/redis:7.0
    51          options: >-
    52            --health-cmd      "redis-cli ping"
    53            --health-interval 10s
    54            --health-timeout  5s
    55            --health-retries  5
    56          ports:
    57            # Maps tcp port 6379 on service container to the host
    58            - 6379:6379
    59  
    60        # MySQL backend server.
    61        mysql:
    62          image: loads/mysql:5.7
    63          env:
    64            MYSQL_DATABASE     : test
    65            MYSQL_ROOT_PASSWORD: 12345678
    66          ports:
    67            - 3306:3306
    68  
    69        # MariaDb backend server.
    70        mariadb:
    71          image: loads/mariadb:10.4
    72          env:
    73            MARIADB_DATABASE: test
    74            MARIADB_ROOT_PASSWORD: 12345678
    75          ports:
    76            - 3307:3306
    77  
    78        # PostgreSQL backend server.
    79        # docker run -d --name postgres \
    80        # -p 5432:5432 \
    81        # -e POSTGRES_PASSWORD=12345678 \
    82        # -e POSTGRES_USER=postgres \
    83        # -e POSTGRES_DB=test \
    84        # -v postgres:/Users/john/Temp/postgresql/data \
    85        # loads/postgres:13
    86        postgres:
    87          image: loads/postgres:13
    88          env:
    89            POSTGRES_PASSWORD: 12345678
    90            POSTGRES_USER:     postgres
    91            POSTGRES_DB:       test
    92            TZ:                Asia/Shanghai
    93          ports:
    94            - 5432:5432
    95          # Set health checks to wait until postgres has started
    96          options: >-
    97            --health-cmd pg_isready
    98            --health-interval 10s
    99            --health-timeout 5s
   100            --health-retries 5
   101  
   102        # MSSQL backend server.
   103        # docker run \
   104        # -p 1433:1433 \
   105        # -e ACCEPT_EULA=Y \
   106        # -e SA_PASSWORD=LoremIpsum86 \
   107        # -e MSSQL_DB=test \
   108        # -e MSSQL_USER=root \
   109        # -e MSSQL_PASSWORD=LoremIpsum86 \
   110        # loads/mssqldocker:14.0.3391.2
   111        mssql:
   112          image: loads/mssqldocker:14.0.3391.2
   113          env:
   114            ACCEPT_EULA:    Y
   115            SA_PASSWORD:    LoremIpsum86
   116            MSSQL_DB:       test
   117            MSSQL_USER:     root
   118            MSSQL_PASSWORD: LoremIpsum86
   119          ports:
   120            - 1433:1433
   121          options: >-
   122            --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1"
   123            --health-start-period 10s
   124            --health-interval 10s
   125            --health-timeout 5s
   126            --health-retries 10
   127  
   128        # ClickHouse backend server.
   129        # docker run -d --name clickhouse \
   130        # -p 9000:9000 -p 8123:8123 -p 9001:9001 \
   131        # loads/clickhouse-server:22.1.3.7
   132        clickhouse-server:
   133          image: loads/clickhouse-server:22.1.3.7
   134          ports:
   135            - 9000:9000
   136            - 8123:8123
   137            - 9001:9001
   138  
   139        # Polaris backend server.
   140        # docker run -d --name polaris \
   141        # -p 8090:8090 -p 8091:8091 -p 8093:8093 -p 9090:9090 -p 9091:9091 \
   142        # loads/polaris-server-standalone:1.11.2
   143        #
   144        # docker run -d --name polaris \
   145        # -p 8090:8090 -p 8091:8091 -p 8093:8093 -p 9090:9090 -p 9091:9091 \
   146        # loads/polaris-standalone:v1.16.3
   147        polaris:
   148          image: loads/polaris-standalone:v1.17.2
   149          ports:
   150            - 8090:8090
   151            - 8091:8091
   152            - 8093:8093
   153            - 9090:9090
   154            - 9091:9091
   155  
   156        # Oracle 11g server.
   157        # docker run \
   158        # -e ORACLE_ALLOW_REMOTE=true \
   159        # -e ORACLE_SID=XE \
   160        # -e ORACLE_DB_USER_NAME=system \
   161        # -e ORACLE_DB_PASSWORD=oracle \
   162        # -p 1521:1521 \
   163        # loads/oracle-xe-11g-r2:11.2.0
   164        oracle-server:
   165          image: loads/oracle-xe-11g-r2:11.2.0
   166          env:
   167            ORACLE_ALLOW_REMOTE: true
   168            ORACLE_SID: XE
   169            ORACLE_DB_USER_NAME: system
   170            ORACLE_DB_PASSWORD: oracle
   171          ports:
   172            - 1521:1521
   173  
   174        # dm8 server
   175        # docker run -p 5236:5236 loads/dm:v8.1.2.128_ent_x86_64_ctm_pack4
   176        dm-server:
   177          image: loads/dm:v8.1.2.128_ent_x86_64_ctm_pack4
   178          ports:
   179            - 5236:5236
   180  
   181        zookeeper:
   182          image: loads/zookeeper:3.8
   183          ports:
   184            - 2181:2181
   185  
   186      strategy:
   187        matrix:
   188          go-version: [ "1.18", "1.19", "1.20", "1.21", "1.22" ]
   189          goarch: [ "386", "amd64" ]
   190  
   191      steps:
   192      # TODO: szenius/set-timezone update to node16
   193      - name: Setup Timezone
   194        uses: szenius/set-timezone@v1.1
   195        with:
   196          timezoneLinux: "Asia/Shanghai"
   197  
   198      - name: Checkout Repository
   199        uses: actions/checkout@v4
   200  
   201      - name: Start Apollo Containers
   202        run:  docker-compose -f ".github/workflows/apollo/docker-compose.yml" up -d --build
   203        
   204      - name: Start Nacos Containers
   205        run:  docker-compose -f ".github/workflows/nacos/docker-compose.yml" up -d --build
   206  
   207      - name: Start Redis Cluster Containers
   208        run:  docker-compose -f ".github/workflows/redis/docker-compose.yml" up -d --build
   209  
   210      - name: Start Consul Containers
   211        run:  docker-compose -f ".github/workflows/consul/docker-compose.yml" up -d --build
   212  
   213      - name: Setup Golang ${{ matrix.go-version }}
   214        uses: actions/setup-go@v5
   215        with:
   216          go-version: ${{ matrix.go-version }}
   217          cache-dependency-path: '**/go.sum' 
   218  
   219      - name: Before Script
   220        run:  bash .github/workflows/before_script.sh
   221  
   222      - name: Build & Test
   223        if: ${{ (github.event_name == 'push' && github.ref != 'refs/heads/master') || github.event_name == 'pull_request' }}
   224        run: bash .github/workflows/ci-main.sh
   225  
   226      - name: Build & Test & Coverage
   227        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
   228        run: bash .github/workflows/ci-main.sh coverage
   229  
   230      - name: Stop Redis Cluster Containers
   231        run:  docker-compose -f ".github/workflows/redis/docker-compose.yml" down
   232  
   233      - name: Stop Apollo Containers
   234        run:  docker-compose -f ".github/workflows/apollo/docker-compose.yml" down
   235  
   236      - name: Stop Nacos Containers
   237        run:  docker-compose -f ".github/workflows/nacos/docker-compose.yml" down
   238  
   239      - name: Stop Consul Containers
   240        run:  docker-compose -f ".github/workflows/consul/docker-compose.yml" down
   241  
   242      - name: Report Coverage
   243        uses: codecov/codecov-action@v4
   244        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
   245        with:
   246          flags: go-${{ matrix.go-version }}-${{ matrix.goarch }}