-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into feat/pdf-archiver
- Loading branch information
Showing
32 changed files
with
423 additions
and
42 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
dev-data* | ||
docs | ||
!docs/swagger | ||
Dockerfile | ||
*.md | ||
.githooks | ||
.github | ||
.goreleaser.yaml | ||
/.* |
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
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,18 @@ | ||
name: "E2E Tests" | ||
|
||
on: workflow_call | ||
|
||
jobs: | ||
e2e-tests: | ||
runs-on: ubuntu-latest | ||
|
||
name: Tests | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Setup go | ||
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
with: | ||
go-version-file: ./go.mod | ||
|
||
- run: make e2e |
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -23,5 +23,8 @@ dist/ | |
# frontend | ||
node_modules | ||
|
||
# golang | ||
go.work* | ||
|
||
# workaround for buildx using podman | ||
type=docker |
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
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,14 @@ | ||
ARG ALPINE_VERSION | ||
ARG GOLANG_VERSION | ||
|
||
FROM docker.io/golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} | ||
|
||
WORKDIR /src/shiori | ||
|
||
COPY . /src/shiori | ||
|
||
RUN apk --update add git && \ | ||
go run main.go version # Using this to force go dep download by running the main command. | ||
|
||
ENTRYPOINT ["go", "run", "main.go"] | ||
CMD ["server"] |
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
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
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,87 @@ | ||
package e2eutil | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/testcontainers/testcontainers-go" | ||
"github.com/testcontainers/testcontainers-go/wait" | ||
) | ||
|
||
const ( | ||
shioriPort = "8080/tcp" | ||
shioriExpectedStartupMessage = "started http server" | ||
shioriExpectedStartupSeconds = 5 | ||
) | ||
|
||
var testContainersProviderType testcontainers.ProviderType = testcontainers.ProviderDocker | ||
|
||
func init() { | ||
// If TESTCONTAINERS_PROVIDER is set to podman, use podman | ||
// NOTE: This is EXPERIMENTAL since there are some issues running the e2e tests using podman, | ||
// testcontainers implies that it supports podman but I couldn't make it run in my tests. | ||
// YMMV. | ||
// More info: https://golang.testcontainers.org/system_requirements/using_podman/ | ||
if os.Getenv("TESTCONTAINERS_PROVIDER") == "podman" { | ||
testContainersProviderType = testcontainers.ProviderPodman | ||
} | ||
} | ||
|
||
func newBuildArg(value string) *string { | ||
return &value | ||
} | ||
|
||
type ShioriContainer struct { | ||
t *testing.T | ||
|
||
Container testcontainers.Container | ||
} | ||
|
||
func (sc *ShioriContainer) GetPort() string { | ||
mappedPort, err := sc.Container.MappedPort(context.Background(), shioriPort) | ||
require.NoError(sc.t, err) | ||
return mappedPort.Port() | ||
} | ||
|
||
// NewShioriContainer creates a new ShioriContainer which is a wrapper around a testcontainers.Container | ||
// with some helpers for using while running Shiori E2E tests. | ||
func NewShioriContainer(t *testing.T, tag string) ShioriContainer { | ||
containerDefinition := testcontainers.GenericContainerRequest{ | ||
ProviderType: testContainersProviderType, | ||
ContainerRequest: testcontainers.ContainerRequest{ | ||
Cmd: []string{"server", "--log-level", "debug"}, | ||
ExposedPorts: []string{shioriPort}, | ||
WaitingFor: wait.ForLog(shioriExpectedStartupMessage).WithStartupTimeout(shioriExpectedStartupSeconds * time.Second), | ||
}, | ||
Started: true, | ||
} | ||
|
||
if tag != "" { | ||
containerDefinition.ContainerRequest.FromDockerfile = testcontainers.FromDockerfile{} | ||
containerDefinition.Image = "gchr.io/go-shiori/shiori:" + tag | ||
} else { | ||
containerDefinition.FromDockerfile = testcontainers.FromDockerfile{ | ||
Context: "../..", | ||
Dockerfile: "Dockerfile.e2e", | ||
KeepImage: true, | ||
BuildArgs: map[string]*string{ | ||
"ALPINE_VERSION": newBuildArg(os.Getenv("CONTAINER_ALPINE_VERSION")), | ||
"GOLANG_VERSION": newBuildArg(os.Getenv("GOLANG_VERSION")), | ||
}, | ||
} | ||
} | ||
|
||
container, err := testcontainers.GenericContainer(context.Background(), containerDefinition) | ||
require.NoError(t, err) | ||
t.Cleanup(func() { | ||
require.NoError(t, container.Terminate(context.Background())) | ||
}) | ||
|
||
return ShioriContainer{ | ||
t: t, | ||
Container: container, | ||
} | ||
} |
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,19 @@ | ||
package e2e | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/go-shiori/shiori/e2e/e2eutil" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestServerBasic(t *testing.T) { | ||
container := e2eutil.NewShioriContainer(t, "") | ||
|
||
t.Run("liveness endpoint", func(t *testing.T) { | ||
req, err := http.Get("http://localhost:" + container.GetPort() + "/system/liveness") | ||
require.NoError(t, err) | ||
require.Equal(t, http.StatusOK, req.StatusCode) | ||
}) | ||
} |
Oops, something went wrong.