Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
niko0xdev committed Jan 20, 2024
0 parents commit 94b6c84
Show file tree
Hide file tree
Showing 830 changed files with 229,200 additions and 0 deletions.
111 changes: 111 additions & 0 deletions .chglog/CHANGELOG-full-history.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{{- $repourl := $.Info.RepositoryURL -}}
# CHANGELOG
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<a name="unreleased"></a>
## [Unreleased]({{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD)

{{ if .Unreleased.NoteGroups }}
{{ range .Unreleased.NoteGroups -}}
### {{ .Title }}
{{ range .Notes -}}
{{ .Body }}
{{ end -}} <!-- end of Notes -->
{{ end -}} <!-- end of NoteGroups -->
{{ end -}} <!-- end of if -->
{{ range .Unreleased.CommitGroups }}
{{ range .Commits -}}

{{- /** Remove markdown urls when there's a pull request linked and replace it with a tag **/ -}}
{{- $subject := (regexReplaceAll `URL` (regexReplaceAll `\[#(\d+)\]\(.*?\)` .Subject "<a href=\"URL/pull/${1}\">#${1}</a>") $repourl) -}}
{{- /** Filter out refs mentioned in the title **/ -}}
{{- $list := (list) -}}
{{- range $idx, $ref := .Refs -}}
{{- if not (regexMatch $ref.Ref $subject) -}}
{{ $list = append $list $ref }}
{{- end -}}
{{- end -}}
{{- /** end custom variables **/ -}}

{{ if .TrimmedBody -}}<dl><dd><details><summary>{{ else -}}- {{ end -}}
<a href="{{$repourl}}/commit/{{.Hash.Long}}"><tt>{{.Hash.Short}}</tt></a> {{ $subject }}
{{- if $list -}}
{{ printf " %s " "(closes"}}
{{- range $idx, $ref := $list -}}{{ if $idx }}, {{ end -}}
<a href="{{ $repourl }}/issues/{{ $ref.Ref}}"> #{{ $ref.Ref}}</a>{{ end }})
{{- end -}}
{{ if .TrimmedBody -}}</summary>{{ printf "\n\n%s\n\n" .TrimmedBody }}</details></dd></dl>{{ end }}

{{ end }} <!-- end of Commits -->
{{ end -}} <!-- end of CommitGroups -->

{{- if .Versions }}
{{ range .Versions -}}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}[{{ .Tag.Name }}](https://github.com/niko0xdev/gqlgen/releases/tag/{{ .Tag.Name }}){{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
{{- if .CommitGroups -}}
{{ range .CommitGroups -}}

### {{ .Title }}
{{ range .Commits -}}
{{- /** Remove markdown urls when there's a pull request linked and replace it with a tag **/ -}}
{{- $subject := (regexReplaceAll `URL` (regexReplaceAll `\[#(\d+)\]\(.*?\)` .Subject "<a href=\"URL/pull/${1}\">#${1}</a>") $repourl) -}}
{{- /** Filter out refs mentioned in the title **/ -}}
{{- $list := (list) -}}
{{- range $idx, $ref := .Refs -}}
{{- if not (regexMatch $ref.Ref $subject) -}}
{{ $list = append $list $ref }}
{{- end -}}
{{- end -}}
{{- /** end custom varaibles **/ -}}

{{ if .TrimmedBody -}}<dl><dd><details><summary>{{ else -}}- {{ end -}}
<a href="{{$repourl}}/commit/{{.Hash.Long}}"><tt>{{.Hash.Short}}</tt></a> {{ $subject }}
{{- if $list -}}
{{ printf " %s " "(closes"}}
{{- range $idx, $ref := $list -}}{{ if $idx }}, {{ end -}}
<a href="{{ $repourl }}/issues/{{ $ref.Ref}}"> #{{ $ref.Ref}}</a>{{ end }})
{{- end -}}

- {{ if .Type }}**{{ .Type }}:** {{ end }}{{ if .Subject }}{{ .Subject }}{{ else }}{{ .Header }}{{ end }}
{{ end }} <!-- end of Commits -->
{{ end -}} <!-- end of CommitGroups -->
{{ else }}
{{ range .Commits -}}

{{- /** Remove markdown urls when there's a pull request linked and replace it with a tag **/ -}}
{{- $subject := (regexReplaceAll `URL` (regexReplaceAll `\[#(\d+)\]\(.*?\)` .Subject "<a href=\"URL/pull/${1}\">#${1}</a>") $repourl) -}}
{{- /** Filter out refs mentioned in the title **/ -}}
{{- $list := (list) -}}
{{- range $idx, $ref := .Refs -}}
{{- if not (regexMatch $ref.Ref $subject) -}}
{{ $list = append $list $ref }}
{{- end -}}
{{- end -}}
{{- /** end custom variables **/ -}}

{{ if .TrimmedBody -}}<dl><dd><details><summary>{{ else -}}- {{ end -}}
<a href="{{$repourl}}/commit/{{.Hash.Long}}"><tt>{{.Hash.Short}}</tt></a> {{ $subject }}
{{- if $list -}}
{{ printf " %s " "(closes"}}
{{- range $idx, $ref := $list -}}{{ if $idx }}, {{ end -}}
<a href="{{ $repourl }}/issues/{{ $ref.Ref}}"> #{{ $ref.Ref}}</a>{{ end }})
{{- end -}}
{{ if .TrimmedBody -}}</summary>{{ printf "\n\n%s\n\n" .TrimmedBody }}</details></dd></dl>{{ end }}

{{ end }} <!-- end of Commits -->
{{ end -}} <!-- end of Else -->

{{ if .NoteGroups }}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes -}}
{{ .Body }}
{{ end -}} <!-- end of Notes -->
{{ end -}} <!-- end of NoteGroups -->
{{ end -}} <!-- end of If NoteGroups -->
{{ end -}} <!-- end of Versions -->
{{ end -}} <!-- end of If Versions -->
18 changes: 18 additions & 0 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
style: github
template: CHANGELOG-full-history.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/niko0xdev/gqlgen
options:
commits:
# filters:
# Type: []
commit_groups:
# title_maps: []
header:
pattern: "^(.*)$"
pattern_maps:
- Subject
notes:
keywords:
- BREAKING CHANGE
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/**/node_modules
/codegen/tests/gen
/vendor
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[*.{go,gotpl}]
indent_style = tab

[*.yml]
indent_size = 2

# These often end up with go code inside, so lets keep tabs
[*.{html,md}]
indent_size = 2
indent_style = tab
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/codegen/templates/data.go linguist-generated
/_examples/dataloader/*_gen.go linguist-generated
generated.go linguist-generated
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### What happened?

### What did you expect?

### Minimal graphql.schema and models to reproduce

### versions
- `go run github.com/niko0xdev/gqlgen version`?
- `go version`?
5 changes: 5 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Describe your PR and link to any relevant issues.

I have:
- [ ] Added tests covering the bug / feature (see [testing](https://github.com/niko0xdev/gqlgen/blob/master/TESTING.md))
- [ ] Updated any relevant documentation (see [docs](https://github.com/niko0xdev/gqlgen/tree/master/docs/content))
10 changes: 10 additions & 0 deletions .github/workflows/check-coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -euo pipefail
GO111MODULE=off go get github.com/mattn/goveralls

go test -covermode atomic -coverprofile=/tmp/coverage.out.tmp -coverpkg=./... $(go list github.com/niko0xdev/gqlgen/... | grep -v _examples)
# ignore protobuf files
cat /tmp/coverage.out.tmp | grep -v ".pb.go" > /tmp/coverage.out

goveralls -coverprofile=/tmp/coverage.out -service=github -ignore='_examples/*/*,_examples/*/*/*,integration/*,integration/*/*,codegen/testserver/*/*,plugin/federation/testdata/*/*/*,*/generated.go,*/*/generated.go,*/*/*/generated.go,graphql/executable_schema_mock.go'
22 changes: 22 additions & 0 deletions .github/workflows/check-federation
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -euo pipefail

cd _examples/federation

./start.sh &

sleep 5
curl -s --connect-timeout 5 \
--max-time 10 \
--retry 5 \
--retry-delay 5 \
--retry-max-time 40 \
--retry-connrefused \
localhost:4003 > /dev/null

sleep 1

echo "### running jest integration spec"
./node_modules/.bin/jest --color

11 changes: 11 additions & 0 deletions .github/workflows/check-fmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -euo pipefail

go fmt ./...
cd _examples && go fmt ./...
if [[ $(git --no-pager diff) ]] ; then
echo "you need to run "go fmt" and commit the changes"
git --no-pager diff
exit 1
fi
11 changes: 11 additions & 0 deletions .github/workflows/check-generate
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -euo pipefail

go generate ./...
cd _examples && go generate ./...
if [[ $(git --no-pager diff) ]] ; then
echo "you need to run "go generate ./..." and commit the changes"
git --no-pager diff
exit 1
fi
21 changes: 21 additions & 0 deletions .github/workflows/check-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -euo pipefail

gqlgen_dir=$(pwd)
cd $(mktemp -d)
go mod init inittest
printf '// +build tools\npackage tools\nimport _ "github.com/niko0xdev/gqlgen"' | gofmt > tools.go
go mod tidy
go mod edit -replace=github.com/niko0xdev/gqlgen="$gqlgen_dir"
go mod tidy

if ! go run github.com/niko0xdev/gqlgen init ; then
echo "gqlgen init failed"
exit 125
fi

if ! go run github.com/niko0xdev/gqlgen generate ; then
echo "gqlgen generate failed"
exit 125
fi
29 changes: 29 additions & 0 deletions .github/workflows/check-integration
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -euo pipefail

cd integration

date
go run ./server/cmd/integration/server.go &

sleep 5
curl -s --connect-timeout 5 \
--max-time 10 \
--retry 5 \
--retry-delay 5 \
--retry-max-time 40 \
--retry-connrefused \
localhost:8080 > /dev/null


echo "### validating introspected schema"
npm run gen

if ! diff <(tail -n +3 src/generated/schema-expected.graphql) <(tail -n +3 src/generated/schema-fetched.graphql) ; then
echo "The expected schema has changed, you need to update schema-expected.graphql with any expected changes"
exit 1
fi

echo "### running integration spec"
npm run test
56 changes: 56 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Integration
on: [push, pull_request]
# When a new revision is pushed to a PR, cancel all in-progress CI runs for that
# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
integration:
strategy:
matrix:
go: ["1.18", "1.20"]
node: [18]
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: go mod download
- run: cd integration ; npm ci
- run: .github/workflows/check-integration

federation:
strategy:
matrix:
go: ["1.18", "1.20"]
node: [14]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: go mod download
- run: cd _examples/federation ; npm install
- run: .github/workflows/check-federation

init:
strategy:
matrix:
go: ["1.18", "1.20"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- run: .github/workflows/check-init
55 changes: 55 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Lint
on: [push, pull_request]
# When a new revision is pushed to a PR, cancel all in-progress CI runs for that
# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
strategy:
matrix:
go: ["1.19", "1.20"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- run: go mod download
- run: .github/workflows/check-fmt
- run: .github/workflows/check-generate

coverage:
strategy:
matrix:
go: ["1.19", "1.20"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- run: go mod download
- run: .github/workflows/check-coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

golangci-lint:
strategy:
matrix:
go: ["1.19", "1.20"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v3.5.0
with:
version: latest
# skip cache because of flaky behaviors
skip-build-cache: true
skip-pkg-cache: true
args: '--timeout 5m'

0 comments on commit 94b6c84

Please sign in to comment.