Skip to content

Commit

Permalink
GitHub CI action (#760)
Browse files Browse the repository at this point in the history
  • Loading branch information
cretz authored Mar 24, 2022
1 parent 55cf584 commit 48b3cb9
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Continuous Integration
on:
pull_request:
push:
branches:
- main
- 'releases/*'

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Print build information
run: "echo head_ref: ${{ github.head_ref }}, ref: ${{ github.ref }}"
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-go@v2
with:
go-version: "1.17"
- name: Check and unit test
run: make check unit-test
- name: Clone Temporal Docker compose
uses: actions/checkout@v2
with:
repository: temporalio/docker-compose
path: ./docker-compose
- name: Start Temporal server
run: |
docker-compose --project-directory ./docker-compose up &
go run ./.github/workflows/wait_for_server.go
- name: Integration tests (without cache)
run: make integration-test-zero-cache
- name: Integration tests (with cache)
run: make integration-test-normal-cache
44 changes: 44 additions & 0 deletions .github/workflows/wait_for_server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// The MIT License
//
// Copyright (c) 2022 Temporal Technologies Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package main

import (
"log"
"time"

"go.temporal.io/sdk/client"
)

func main() {
// We'll try to connect every two seconds for 5 minutes
log.Print("Waiting for server availability")
var lastErr error
for start := time.Now(); time.Since(start) < 5*time.Minute; time.Sleep(2 * time.Second) {
_, lastErr = client.NewClient(client.Options{})
if lastErr == nil {
log.Print("Connected to server")
return
}
}
log.Fatalf("Timeout waiting for server, last error: %v", lastErr)
}

0 comments on commit 48b3cb9

Please sign in to comment.