Skip to content

Commit 1bf5db1

Browse files
authored
Merge branch 'main' into ivo/bson_m
2 parents e9e2a86 + 2158073 commit 1bf5db1

19 files changed

+578
-254
lines changed

.github/dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ updates:
33
- package-ecosystem: docker
44
directory: "/"
55
schedule:
6-
interval: weekly
6+
interval: monthly

.github/workflows/ci_release.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Release
2+
on:
3+
push:
4+
# Nightly schedule pending full e2e testing with other repos
5+
#schedule:
6+
# Run daily at 1:15am
7+
#- cron: "15 1 * * *"
8+
workflow_dispatch:
9+
# Inputs the workflow accepts.
10+
inputs:
11+
version:
12+
# Friendly description to be shown in the UI instead of 'name'
13+
description: "Semver type of new version (major / minor / patch)"
14+
# Input has to be provided for the workflow to run
15+
required: true
16+
type: choice
17+
options:
18+
- patch
19+
- minor
20+
- major
21+
22+
jobs:
23+
# Run the linting and tests
24+
hadolint:
25+
uses: SkynetLabs/.github/.github/workflows/reusable_dockerfile_lint.yml@master
26+
27+
test:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Check out repository code
31+
uses: actions/checkout@v3
32+
- uses: actions/setup-go@v2
33+
with:
34+
go-version: "1.18"
35+
- name: Install analyze
36+
run: go install gitlab.com/NebulousLabs/analyze@latest
37+
- name: Install golangci-lint
38+
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.0
39+
- name: Lint
40+
run: make lint
41+
- name: Run unit tests
42+
run: make test
43+
44+
# Check if there were any changes since the last tag if this is not a push
45+
# event
46+
changes:
47+
needs: [hadolint, test]
48+
runs-on: ubuntu-latest
49+
outputs:
50+
updates: ${{steps.changes.outputs.any == 'true'}}
51+
if: ${{ github.event_name != 'push' }}
52+
steps:
53+
- uses: actions/checkout@v3
54+
with:
55+
fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags
56+
- uses: SkynetLabs/.github/.github/actions/changes-since-last-tag@master
57+
58+
# Make a release if
59+
# - there were changes and this is a scheduled job
60+
# - This is a manually trigger job, i.e. workflow_dispatch
61+
release:
62+
needs: changes
63+
runs-on: ubuntu-latest
64+
if: ${{ (needs.changes.outputs.updates == 'true' && github.event_name == 'schedule') || github.event_name == 'workflow_dispatch' }}
65+
steps:
66+
- uses: actions/checkout@v3
67+
- name: Version Release
68+
uses: SkynetLabs/.github/.github/actions/version-release@master
69+
with:
70+
github-token: ${{secrets.GITHUB_TOKEN}}
71+
version-bump: ${{inputs.version}}

.github/workflows/dockerfile-lint.yml

-16
This file was deleted.

.github/workflows/github-actions-demo.yml

-19
This file was deleted.

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ COPY . .
99

1010
RUN go mod download && make release
1111

12-
FROM alpine:3.15.3
12+
FROM alpine:3.15.4
1313
LABEL maintainer="SkynetLabs <[email protected]>"
1414

1515
COPY --from=builder /go/bin/skynet-accounts /usr/bin/skynet-accounts

api/cache_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ func TestUserTierCache(t *testing.T) {
1313
u := &database.User{
1414
Sub: t.Name(),
1515
Tier: database.TierPremium5,
16+
CreatedAt: time.Now().UTC(),
1617
SubscribedUntil: time.Now().UTC().Add(100 * time.Hour),
1718
QuotaExceeded: false,
1819
}

api/handlers.go

+4-17
Original file line numberDiff line numberDiff line change
@@ -1013,11 +1013,6 @@ func (api *API) userRecoverRequestPOST(_ *database.User, w http.ResponseWriter,
10131013
api.WriteError(w, errors.AddContext(err, "failed to fetch the user with this email"), http.StatusInternalServerError)
10141014
return
10151015
}
1016-
// Verify that the user's email is confirmed.
1017-
if u.EmailConfirmationToken != "" {
1018-
api.WriteError(w, errors.New("user's email is not confirmed. it cannot be used for account recovery"), http.StatusBadRequest)
1019-
return
1020-
}
10211016
// Generate a new recovery token and add it to the user's account.
10221017
u.RecoveryToken, err = lib.GenerateUUID()
10231018
if err != nil {
@@ -1200,22 +1195,14 @@ func (api *API) trackDownloadPOST(u *database.User, w http.ResponseWriter, req *
12001195
}
12011196

12021197
// trackRegistryReadPOST registers a new registry read in the system.
1203-
func (api *API) trackRegistryReadPOST(u *database.User, w http.ResponseWriter, req *http.Request, _ httprouter.Params) {
1204-
_, err := api.staticDB.RegistryReadCreate(req.Context(), *u)
1205-
if err != nil {
1206-
api.WriteError(w, err, http.StatusInternalServerError)
1207-
return
1208-
}
1198+
func (api *API) trackRegistryReadPOST(_ *database.User, w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
1199+
// Tracking registry reads is disabled.
12091200
api.WriteSuccess(w)
12101201
}
12111202

12121203
// trackRegistryWritePOST registers a new registry write in the system.
1213-
func (api *API) trackRegistryWritePOST(u *database.User, w http.ResponseWriter, req *http.Request, _ httprouter.Params) {
1214-
_, err := api.staticDB.RegistryWriteCreate(req.Context(), *u)
1215-
if err != nil {
1216-
api.WriteError(w, err, http.StatusInternalServerError)
1217-
return
1218-
}
1204+
func (api *API) trackRegistryWritePOST(_ *database.User, w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
1205+
// Tracking registry writes is disabled.
12191206
api.WriteSuccess(w)
12201207
}
12211208

api/routes.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ func (api *API) buildHTTPRoutes() {
7777
api.staticRouter.POST("/user/recover/request", api.WithDBSession(api.noAuth(api.userRecoverRequestPOST)))
7878
api.staticRouter.POST("/user/recover", api.WithDBSession(api.noAuth(api.userRecoverPOST)))
7979

80-
api.staticRouter.POST("/stripe/webhook", api.WithDBSession(api.noAuth(api.stripeWebhookPOST)))
80+
api.staticRouter.POST("/stripe/billing", api.WithDBSession(api.withAuth(api.stripeBillingPOST, false)))
81+
api.staticRouter.POST("/stripe/checkout", api.WithDBSession(api.withAuth(api.stripeCheckoutPOST, false)))
8182
api.staticRouter.GET("/stripe/prices", api.noAuth(api.stripePricesGET))
83+
api.staticRouter.POST("/stripe/webhook", api.WithDBSession(api.noAuth(api.stripeWebhookPOST)))
8284

8385
api.staticRouter.GET("/.well-known/jwks.json", api.noAuth(api.wellKnownJWKSGET))
8486

0 commit comments

Comments
 (0)