Skip to content

Commit

Permalink
Add github actions CI/CD for building, testing and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyTitu committed Jan 18, 2024
1 parent 1c79213 commit d71c5fe
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will build, test and check linting for the 1Password Go SDK.
name: Validate

on:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'

jobs:

validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '^1.21'

- name: Build
run: go build -v ./...

- name: Test
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TEST_SA_TOKEN }}
run: go test -v ./...

- name: Lint with golanci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1
36 changes: 36 additions & 0 deletions integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package onepassword

import (
"context"
"github.com/stretchr/testify/assert"
"os"
"testing"
)

// These tests were designed for CI/CD. If you want to run them locally you must make sure the following dependencies are in place:
// A valid (test) Service Account Token is set in the environment - export OP_SERVICE_ACCOUNT_TOKEN = ...
// Secret references and expected values are matching existing secrets in the test account.

func TestSecretRetrievalFromTestAccount(t *testing.T) {
token := os.Getenv("OP_SERVICE_ACCOUNT_TOKEN")

clientFactory, err := NewClientFactory(context.TODO())
if err != nil {
panic(err)
}

client, err := clientFactory.NewClient(
WithServiceAccountToken(token),
WithIntegrationInfo("Integration_Test_Go_SDK", DefaultIntegrationVersion),
)
if err != nil {
panic(err)
}

secret, err := client.Secrets.Resolve("op://xw33qlvug6moegr3wkk5zkenoa/bckakdku7bgbnyxvqbkpehifki/foobar")
if err != nil {
panic(err)
}

assert.Equal(t, "test_password", secret)
}

0 comments on commit d71c5fe

Please sign in to comment.