CI (Go SDK) #223
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2024 ScopeDB, Inc. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: CI (Go SDK) | |
on: | |
pull_request: | |
branches: [ main ] | |
paths: [ 'go/**' ] | |
schedule: | |
# ScopeDB edge is cut every day at 02:04, so we run the CI at 04:02 to ensure the latest version is tested. | |
- cron: '2 4 * * *' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
check: | |
name: Check | |
runs-on: ubuntu-22.04 | |
if: ${{ github.event_name != 'schedule' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: go/go.mod | |
cache-dependency-path: go/go.sum | |
- run: make check | |
working-directory: go | |
test: | |
name: Build and test | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: go/go.mod | |
cache-dependency-path: go/go.sum | |
- run: make build | |
working-directory: go | |
- name: Prepare Composed Environment | |
if: ${{ github.repository == 'scopedb/scopedb-sdk' }} | |
run: docker compose -f ./dev/docker-compose.yml up -d | |
- name: Run full tests | |
if: ${{ github.repository == 'scopedb/scopedb-sdk' }} | |
timeout-minutes: 10 | |
run: make ci-test | |
working-directory: go | |
- name: Run tests | |
if: ${{ github.repository != 'scopedb/scopedb-sdk' }} | |
timeout-minutes: 10 | |
run: make test | |
working-directory: go | |
- name: Upload server logs | |
if: ${{ !success() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: server-logs | |
path: dev/logs | |
required: | |
name: Required | |
runs-on: ubuntu-22.04 | |
if: ${{ always() }} | |
needs: | |
- check | |
- test | |
steps: | |
- name: Guardian | |
run: | | |
if [[ ! ( \ | |
("${{ needs.check.result }}" == "success" || ${{ github.event_name != 'schedule' }}) \ | |
&& "${{ needs.test.result }}" == "success" \ | |
) ]]; then | |
echo "Required jobs haven't been completed successfully." | |
exit -1 | |
fi |