-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github actions CI/CD for building, testing and linting
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 |
This file contains 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
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) | ||
} |