github.com/gogf/gf/v2@v2.7.4/.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        # docker run -d --name mysql \
    62        # -p 3306:3306 \
    63        # -e MYSQL_DATABASE=test \
    64        # -e MYSQL_ROOT_PASSWORD=12345678 \
    65        # loads/mysql:5.7
    66        mysql:
    67          image: loads/mysql:5.7
    68          env:
    69            MYSQL_DATABASE     : test
    70            MYSQL_ROOT_PASSWORD: 12345678
    71          ports:
    72            - 3306:3306
    73  
    74        # MariaDb backend server.
    75        mariadb:
    76          image: loads/mariadb:10.4
    77          env:
    78            MARIADB_DATABASE: test
    79            MARIADB_ROOT_PASSWORD: 12345678
    80          ports:
    81            - 3307:3306
    82  
    83        # PostgreSQL backend server.
    84        # docker run -d --name postgres \
    85        # -p 5432:5432 \
    86        # -e POSTGRES_PASSWORD=12345678 \
    87        # -e POSTGRES_USER=postgres \
    88        # -e POSTGRES_DB=test \
    89        # -v postgres:/Users/john/Temp/postgresql/data \
    90        # loads/postgres:13
    91        postgres:
    92          image: loads/postgres:13
    93          env:
    94            POSTGRES_PASSWORD: 12345678
    95            POSTGRES_USER:     postgres
    96            POSTGRES_DB:       test
    97            TZ:                Asia/Shanghai
    98          ports:
    99            - 5432:5432
   100          # Set health checks to wait until postgres has started
   101          options: >-
   102            --health-cmd pg_isready
   103            --health-interval 10s
   104            --health-timeout 5s
   105            --health-retries 5
   106  
   107        # MSSQL backend server.
   108        # docker run \
   109        # -p 1433:1433 \
   110        # -e ACCEPT_EULA=Y \
   111        # -e SA_PASSWORD=LoremIpsum86 \
   112        # -e MSSQL_DB=test \
   113        # -e MSSQL_USER=root \
   114        # -e MSSQL_PASSWORD=LoremIpsum86 \
   115        # loads/mssqldocker:14.0.3391.2
   116  
   117  # TODO mssql docker failed, will be enabled later after it is OK in github action.
   118  #      mssql:
   119  #        image: loads/mssqldocker:14.0.3391.2
   120  #        env:
   121  #          ACCEPT_EULA:    Y
   122  #          SA_PASSWORD:    LoremIpsum86
   123  #          MSSQL_DB:       test
   124  #          MSSQL_USER:     root
   125  #          MSSQL_PASSWORD: LoremIpsum86
   126  #        ports:
   127  #          - 1433:1433
   128  #        options: >-
   129  #          --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1"
   130  #          --health-start-period 10s
   131  #          --health-interval 10s
   132  #          --health-timeout 5s
   133  #          --health-retries 10
   134  
   135        # ClickHouse backend server.
   136        # docker run -d --name clickhouse \
   137        # -p 9000:9000 -p 8123:8123 -p 9001:9001 \
   138        # loads/clickhouse-server:22.1.3.7
   139        clickhouse-server:
   140          image: loads/clickhouse-server:22.1.3.7
   141          ports:
   142            - 9000:9000
   143            - 8123:8123
   144            - 9001:9001
   145  
   146        # Polaris backend server.
   147        # docker run -d --name polaris \
   148        # -p 8090:8090 -p 8091:8091 -p 8093:8093 -p 9090:9090 -p 9091:9091 \
   149        # loads/polaris-server-standalone:1.11.2
   150        #
   151        # docker run -d --name polaris \
   152        # -p 8090:8090 -p 8091:8091 -p 8093:8093 -p 9090:9090 -p 9091:9091 \
   153        # loads/polaris-standalone:v1.16.3
   154        polaris:
   155          image: loads/polaris-standalone:v1.17.2
   156          ports:
   157            - 8090:8090
   158            - 8091:8091
   159            - 8093:8093
   160            - 9090:9090
   161            - 9091:9091
   162  
   163        # Oracle 11g server.
   164        # docker run \
   165        # -e ORACLE_ALLOW_REMOTE=true \
   166        # -e ORACLE_SID=XE \
   167        # -e ORACLE_DB_USER_NAME=system \
   168        # -e ORACLE_DB_PASSWORD=oracle \
   169        # -p 1521:1521 \
   170        # loads/oracle-xe-11g-r2:11.2.0
   171        oracle-server:
   172          image: loads/oracle-xe-11g-r2:11.2.0
   173          env:
   174            ORACLE_ALLOW_REMOTE: true
   175            ORACLE_SID: XE
   176            ORACLE_DB_USER_NAME: system
   177            ORACLE_DB_PASSWORD: oracle
   178          ports:
   179            - 1521:1521
   180  
   181        # dm8 server
   182        # docker run -p 5236:5236 loads/dm:v8.1.2.128_ent_x86_64_ctm_pack4
   183        dm-server:
   184          image: loads/dm:v8.1.2.128_ent_x86_64_ctm_pack4
   185          ports:
   186            - 5236:5236
   187  
   188        zookeeper:
   189          image: loads/zookeeper:3.8
   190          ports:
   191            - 2181:2181
   192  
   193      strategy:
   194        matrix:
   195          go-version: [ "1.18", "1.19", "1.20", "1.21", "1.22", "1.23" ]
   196          goarch: [ "386", "amd64" ]
   197  
   198      steps:
   199      # TODO: szenius/set-timezone update to node16
   200      # sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
   201      - name: Setup Timezone
   202        uses: szenius/set-timezone@v2.0
   203        with:
   204          timezoneLinux: "Asia/Shanghai"
   205  
   206      - name: Checkout Repository
   207        uses: actions/checkout@v4
   208  
   209      - name: Start Apollo Containers
   210        run:  docker compose -f ".github/workflows/apollo/docker-compose.yml" up -d --build
   211        
   212      - name: Start Nacos Containers
   213        run:  docker compose -f ".github/workflows/nacos/docker-compose.yml" up -d --build
   214  
   215      - name: Start Redis Cluster Containers
   216        run:  docker compose -f ".github/workflows/redis/docker-compose.yml" up -d --build
   217  
   218      - name: Start Consul Containers
   219        run:  docker compose -f ".github/workflows/consul/docker-compose.yml" up -d --build
   220  
   221      - name: Setup Golang ${{ matrix.go-version }}
   222        uses: actions/setup-go@v5
   223        with:
   224          go-version: ${{ matrix.go-version }}
   225          cache-dependency-path: '**/go.sum' 
   226  
   227      - name: Before Script
   228        run:  bash .github/workflows/before_script.sh
   229  
   230      - name: Build & Test
   231        if: ${{ (github.event_name == 'push' && github.ref != 'refs/heads/master') || github.event_name == 'pull_request' }}
   232        run: bash .github/workflows/ci-main.sh
   233  
   234      - name: Build & Test & Coverage
   235        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
   236        run: bash .github/workflows/ci-main.sh coverage
   237  
   238      - name: Stop Redis Cluster Containers
   239        run:  docker compose -f ".github/workflows/redis/docker-compose.yml" down
   240  
   241      - name: Stop Apollo Containers
   242        run:  docker compose -f ".github/workflows/apollo/docker-compose.yml" down
   243  
   244      - name: Stop Nacos Containers
   245        run:  docker compose -f ".github/workflows/nacos/docker-compose.yml" down
   246  
   247      - name: Stop Consul Containers
   248        run:  docker compose -f ".github/workflows/consul/docker-compose.yml" down
   249  
   250      - name: Report Coverage
   251        uses: codecov/codecov-action@v4
   252        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
   253        with:
   254          flags: go-${{ matrix.go-version }}-${{ matrix.goarch }}
   255          token: ${{ secrets.CODECOV_TOKEN }}