go.mercari.io/datastore@v1.8.2/.github/workflows/cicd.yml (about)

     1  name: 'CI'
     2  
     3  on:
     4    push:
     5      branches:
     6        - master
     7    pull_request_target: {}
     8  
     9  env:
    10    GCLOUD_VERSION: "355.0.0"
    11  
    12  jobs:
    13    test:
    14      name: Test
    15      runs-on: ubuntu-latest
    16      continue-on-error: true
    17      strategy:
    18        matrix:
    19          go_version:
    20            - ~1.11
    21            - ~1.12
    22            - ~1.16
    23      permissions:
    24        contents: read
    25      services:
    26        # 本当はservicesで動かしたいけどオプションを指定して実行ができないっぽいので諦めるしかない…
    27        # datastore_emulator:
    28        #   image: gcr.io/google.com/cloudsdktool/cloud-sdk:355.0.0
    29        #   ports:
    30        #     - "8081:8081"
    31        #   options: |-
    32        #     --entrypoint "gcloud --project=datastore-wrapper beta emulators datastore start --host-port=0.0.0.0:8081 --no-store-on-disk --consistency=1.0"
    33        #     --health-cmd "curl http://localhost:8081 --silent --retry-connrefused"
    34        #     --health-interval 1s
    35        #     --health-retries 30
    36        redis:
    37          image: redis:6-alpine
    38          ports:
    39            - "6379:6379"
    40        memcached:
    41          image: memcached:1.6-alpine
    42          ports:
    43            - "11211:11211"
    44      env:
    45        GO111MODULE: "on"
    46        DATASTORE_EMULATOR_HOST: "localhost:8081"
    47        DATASTORE_PROJECT_ID:    "unittest"
    48        MEMCACHED_HOST: "localhost:11211"
    49        GOOGLE_CLOUD_PROJECT: "unittest"
    50      steps:
    51        - uses: actions/checkout@v3
    52          with:
    53            # pull_request_target の場合PRのhead(場合によってはvulnerable)、そうじゃなければcontextのsha
    54            ref: ${{ github.event.pull_request.head.sha || github.sha }}
    55        - uses: actions/setup-go@v3
    56          with:
    57            go-version: ${{ matrix.go_version }}
    58        - name: Cache go dependencies
    59          uses: actions/cache@v3
    60          id: cache
    61          with:
    62            key: ${{ runner.os }}-go-cache-r1-${{ matrix.go_version }}-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
    63            path: |-
    64              ~/go/pkg/mod
    65              build-cmd
    66        - name: Prepare dependencies
    67          if: steps.cache.outputs.cache-hit != 'true'
    68          run: |-
    69            ./setup.sh
    70            ls -la build-cmd
    71        - uses: google-github-actions/setup-gcloud@v0
    72          with:
    73            version: ${{ env.GCLOUD_VERSION }}
    74            project_id: ${{ env.DATASTORE_PROJECT_ID }}
    75            install_components: "beta,cloud-datastore-emulator,app-engine-go"
    76        - name: Spinup Datastore Emulator
    77          run: |-
    78            gcloud beta emulators datastore start --host-port=0.0.0.0:8081 --no-store-on-disk --consistency=1.0 &
    79            curl http://localhost:8081 --silent --retry 30 --retry-connrefused --retry-delay 1
    80        - name: Run tests
    81          run: |-
    82            ./test.sh -v -timeout 4m