Skip to content

Commit

Permalink
Merge pull request #265 from OpsLevel/kr/enum-gen-workflow
Browse files Browse the repository at this point in the history
make a enum gen workflow
  • Loading branch information
rocktavious authored Oct 3, 2023
2 parents 346fb4a + 3cd168e commit d85fb2a
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 47 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/enum-gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Enum Gen"

on:
workflow_dispatch: {}

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"
- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Tests
run: |-
task setup
task generate
- name: Ensure Changelog
run: |
git config user.name "OpsLevel Bots"
git config user.email "[email protected]"
git add enum.go
git commit -m "Regenerate enum.go"
git push origin HEAD:bot/enum-gen
gh pr create --title "Regenerate enum.go" --body "Regenerate enum.go"
24 changes: 12 additions & 12 deletions check_has_owner.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
package opslevel

type ServiceOwnershipCheckFragment struct {
RequireContactMethod *bool `graphql:"requireContactMethod"`
ContactMethod *ServiceOwnershipCheckContactType `graphql:"contactMethod"`
TeamTagKey string `graphql:"tagKey"`
TeamTagPredicate *Predicate `graphql:"tagPredicate"`
RequireContactMethod *bool `graphql:"requireContactMethod"`
ContactMethod *ContactType `graphql:"contactMethod"`
TeamTagKey string `graphql:"tagKey"`
TeamTagPredicate *Predicate `graphql:"tagPredicate"`
}

type CheckServiceOwnershipCreateInput struct {
CheckCreateInput

RequireContactMethod *bool `json:"requireContactMethod,omitempty"`
ContactMethod *ServiceOwnershipCheckContactType `json:"contactMethod,omitempty"`
TeamTagKey string `json:"tagKey,omitempty"`
TeamTagPredicate *PredicateInput `json:"tagPredicate,omitempty"`
RequireContactMethod *bool `json:"requireContactMethod,omitempty"`
ContactMethod *ContactType `json:"contactMethod,omitempty"`
TeamTagKey string `json:"tagKey,omitempty"`
TeamTagPredicate *PredicateInput `json:"tagPredicate,omitempty"`
}

type CheckServiceOwnershipUpdateInput struct {
CheckUpdateInput

RequireContactMethod *bool `json:"requireContactMethod,omitempty"`
ContactMethod *ServiceOwnershipCheckContactType `json:"contactMethod,omitempty"`
TeamTagKey string `json:"tagKey,omitempty"`
TeamTagPredicate *PredicateUpdateInput `json:"tagPredicate,omitempty"`
RequireContactMethod *bool `json:"requireContactMethod,omitempty"`
ContactMethod *ContactType `json:"contactMethod,omitempty"`
TeamTagKey string `json:"tagKey,omitempty"`
TeamTagPredicate *PredicateUpdateInput `json:"tagPredicate,omitempty"`
}

func (client *Client) CreateCheckServiceOwnership(input CheckServiceOwnershipCreateInput) (*Check, error) {
Expand Down
4 changes: 2 additions & 2 deletions check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ var testcases = map[string]struct {
"CreateServiceOwnership": {
fixture: "check/create_service_ownership",
body: func(c *ol.Client) (*ol.Check, error) {
slackType := ol.ServiceOwnershipCheckContactTypeSlack
slackType := ol.ContactTypeSlack
return c.CreateCheckServiceOwnership(ol.CheckServiceOwnershipCreateInput{
CheckCreateInput: checkCreateInput,
RequireContactMethod: ol.Bool(true),
Expand All @@ -337,7 +337,7 @@ var testcases = map[string]struct {
"UpdateServiceOwnership": {
fixture: "check/update_service_ownership",
body: func(c *ol.Client) (*ol.Check, error) {
emailType := ol.ServiceOwnershipCheckContactTypeEmail
emailType := ol.ContactTypeEmail
return c.UpdateCheckServiceOwnership(ol.CheckServiceOwnershipUpdateInput{
CheckUpdateInput: checkUpdateInput,
RequireContactMethod: ol.Bool(true),
Expand Down
5 changes: 3 additions & 2 deletions clientGQL.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package opslevel
import (
"context"
"fmt"
"github.com/hashicorp/go-retryablehttp"
"github.com/hasura/go-graphql-client"
"net/http"
"strings"

"github.com/hashicorp/go-retryablehttp"
"github.com/hasura/go-graphql-client"
)

type Client struct {
Expand Down
29 changes: 6 additions & 23 deletions enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions infra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,13 @@ func TestGetInfrastructureResourceTags(t *testing.T) {
// Arrange
requests := []TestRequest{
{
`{"query": "query InfrastructureResourceTags($after:String!$first:Int!$infrastructureResource:IdentifierInput!){account{infrastructureResource(input: $infrastructureResource){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}",
Request: `{"query": "query InfrastructureResourceTags($after:String!$first:Int!$infrastructureResource:IdentifierInput!){account{infrastructureResource(input: $infrastructureResource){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}",
"variables": {
{{ template "first_page_variables" }},
"infrastructureResource": {"id": "Z2lkOi8vb3BzbGV2ZWwvUmVwb3NpdG9yaWVzOjpHaXRsYWIvMTA5ODc"}
}
}`,
`{
Response: `{
"data": {
"account": {
"infrastructureResource": {
Expand Down Expand Up @@ -287,13 +287,13 @@ func TestGetInfrastructureResourceTags(t *testing.T) {
}`,
},
{
`{"query": "query InfrastructureResourceTags($after:String!$first:Int!$infrastructureResource:IdentifierInput!){account{infrastructureResource(input: $infrastructureResource){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}",
Request: `{"query": "query InfrastructureResourceTags($after:String!$first:Int!$infrastructureResource:IdentifierInput!){account{infrastructureResource(input: $infrastructureResource){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}",
"variables": {
{{ template "second_page_variables" }},
"infrastructureResource": {"id": "Z2lkOi8vb3BzbGV2ZWwvUmVwb3NpdG9yaWVzOjpHaXRsYWIvMTA5ODc"}
}
}`,
`{
Response: `{
"data": {
"account": {
"infrastructureResource": {
Expand Down
8 changes: 4 additions & 4 deletions user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,12 @@ func TestGetUserTags(t *testing.T) {
// Arrange
requests := []TestRequest{
{
`{"query": "query UserTagsList($after:String!$first:Int!$user:ID!){account{user(id: $user){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}",
Request: `{"query": "query UserTagsList($after:String!$first:Int!$user:ID!){account{user(id: $user){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}",
"variables": {
{{ template "first_page_variables" }},
"user": "{{ template "id1"}}"
}}`,
`{
Response: `{
"data": {
"account": {
"user": {
Expand Down Expand Up @@ -290,13 +290,13 @@ func TestGetUserTags(t *testing.T) {
}`,
},
{
`{"query": "query UserTagsList($after:String!$first:Int!$user:ID!){account{user(id: $user){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}",
Request: `{"query": "query UserTagsList($after:String!$first:Int!$user:ID!){account{user(id: $user){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}",
"variables": {
{{ template "second_page_variables" }},
"user": "{{ template "id1"}}"
}
}`,
`{
Response: `{
"data": {
"account": {
"user": {
Expand Down

0 comments on commit d85fb2a

Please sign in to comment.