Skip to content

Commit

Permalink
fix: actions
Browse files Browse the repository at this point in the history
  • Loading branch information
WenZu-Zhou committed Oct 12, 2023
1 parent 891e320 commit d3d54b5
Show file tree
Hide file tree
Showing 16 changed files with 237 additions and 35 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2023 ecodeclub
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Integration Test

on:
push:
branches: [ main, dev]
pull_request:
branches: [ main, dev]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'

- name: Test
run: sudo sh ./script/integrate_test.sh
69 changes: 41 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
.PHONY: bench
bench:
@go test -bench=. -benchmem ./...

.PHONY: ut
ut:
@go test -tags=goexperiment.arenas -race ./...

.PHONY: setup
setup:
@sh ./script/setup.sh

.PHONY: fmt
fmt:
@sh ./script/goimports.sh

.PHONY: lint
lint:
@golangci-lint run -c .golangci.yml

.PHONY: tidy
tidy:
@go mod tidy -v

.PHONY: check
check:
@$(MAKE) fmt
@$(MAKE) tidy
.PHONY: bench
bench:
@go test -bench=. -benchmem ./...

.PHONY: ut
ut:
@go test -tags=goexperiment.arenas -race ./...

.PHONY: setup
setup:
@sh ./script/setup.sh

.PHONY: fmt
fmt:
@sh ./script/goimports.sh

.PHONY: lint
lint:
@golangci-lint run -c .golangci.yml

.PHONY: tidy
tidy:
@go mod tidy -v

.PHONY: check
check:
@$(MAKE) fmt
@$(MAKE) tidy

# e2e 测试
.PHONY: e2e
e2e:
sh ./script/integrate_test.sh

.PHONY: e2e_up
e2e_up:
docker compose -f script/integration_test_compose.yml up -d

.PHONY: e2e_down
e2e_down:
docker compose -f script/integration_test_compose.yml down
24 changes: 19 additions & 5 deletions internal/mocks/redis_mock.go

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

14 changes: 14 additions & 0 deletions internal/ratelimit/mocks/ratelimit.mock.go

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

2 changes: 1 addition & 1 deletion internal/ratelimit/redis_slide_window.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 ecodeclub
// Copyright 2023 ecodeclub
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion internal/ratelimit/redis_slide_window_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 ecodeclub
// Copyright 2023 ecodeclub
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
14 changes: 14 additions & 0 deletions internal/ratelimit/types.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 ecodeclub
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ratelimit

import "context"
Expand Down
14 changes: 14 additions & 0 deletions jwt/claims_option.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 ecodeclub
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package jwt

import (
Expand Down
14 changes: 14 additions & 0 deletions jwt/claims_option_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 ecodeclub
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package jwt

import (
Expand Down
14 changes: 14 additions & 0 deletions jwt/management.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 ecodeclub
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package jwt

import (
Expand Down
14 changes: 14 additions & 0 deletions jwt/management_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 ecodeclub
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package jwt

import (
Expand Down
14 changes: 14 additions & 0 deletions jwt/middleware_builder.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 ecodeclub
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package jwt

import (
Expand Down
14 changes: 14 additions & 0 deletions jwt/middleware_builder_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 ecodeclub
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package jwt

import (
Expand Down
14 changes: 14 additions & 0 deletions jwt/types.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 ecodeclub
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package jwt

import (
Expand Down
7 changes: 7 additions & 0 deletions script/integrate_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -e
docker compose -f script/integration_test_compose.yml down
docker compose -f script/integration_test_compose.yml up -d
go test ./... -tags=e2e
docker compose -f script/integration_test_compose.yml down
8 changes: 8 additions & 0 deletions script/integration_test_compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3.0'
services:
redis:
image: 'bitnami/redis:7.2'
environment:
- ALLOW_EMPTY_PASSWORD=yes
ports:
- '16379:6379'

0 comments on commit d3d54b5

Please sign in to comment.