Skip to content

Commit 371f7ae

Browse files
committed
refactor: initial refactor based on developers-italia-api
Refactor the whole API using github.com/italia/developers-italia-api as a new starting point.
1 parent 59ae91a commit 371f7ae

57 files changed

Lines changed: 7201 additions & 2062 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Set update schedule for GitHub Actions
2+
version: 2
3+
updates:
4+
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "weekly"

.github/workflows/go.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on:
2+
push:
3+
branches: [main]
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
linters:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v6
12+
- uses: actions/setup-go@v6
13+
with:
14+
go-version: 1.24.x
15+
- uses: golangci/golangci-lint-action@v9
16+
with:
17+
version: v2.4.0
18+
args: --timeout 3m --verbose

.github/workflows/oas-linter.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
1-
name: goreleaser
2-
31
on:
42
push:
53
tags:
6-
- '*'
4+
- v*
5+
6+
permissions:
7+
# To upload archives as GitHub Releases
8+
contents: write
9+
# To push Docker images to GitHub
10+
packages: write
711

812
jobs:
913
goreleaser:
1014
runs-on: ubuntu-latest
1115
steps:
12-
-
13-
name: Set up Go
14-
uses: actions/setup-go@v2
16+
- uses: actions/setup-go@v6
1517
with:
16-
go-version: ^1.15
17-
id: go
18-
-
19-
name: Checkout
20-
uses: actions/checkout@v2
21-
-
22-
name: Unshallow
23-
run: git fetch --prune --unshallow
24-
-
25-
name: Docker Login
26-
if: success() && startsWith(github.ref, 'refs/tags/v')
18+
go-version: 1.24.x
19+
- uses: actions/checkout@v6
20+
with:
21+
# All history, required for goreleaser
22+
fetch-depth: 0
23+
- # For TagBody, TagSubject or TagContents fields in goreleaser's templates
24+
run: git fetch --force --tags
25+
- # FIXME: goreleaser should already take care of the login
26+
# (see https://github.com/goreleaser/goreleaser/blame/02a3486d4ba59505113a57b438ae567351ed3dab/scripts/entrypoint.sh#L17)
27+
# but it doesn't work for some reason.
28+
run: echo "$GITHUB_TOKEN" | docker login ghcr.io -u docker --password-stdin
2729
env:
28-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
29-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
30-
run: |
31-
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
32-
-
33-
name: Run GoReleaser
34-
uses: goreleaser/goreleaser-action@v2
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
- uses: goreleaser/goreleaser-action@v6
3532
with:
36-
version: latest
33+
version: v1.9.2
3734
args: release --rm-dist
3835
env:
3936
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/spectral.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
on:
2+
push:
3+
branches: [main]
4+
pull_request:
5+
branches: [main]
6+
7+
permissions:
8+
checks: write
9+
10+
jobs:
11+
spectral:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v6
15+
- run: curl --fail -L https://github.com/italia/api-oas-checker-rules/releases/download/1.1/spectral-full.yml > .spectral.yml
16+
17+
# Get additional module required by spectral-full
18+
- run: mkdir functions
19+
- run: curl --fail -L https://raw.githubusercontent.com/italia/api-oas-checker/f6f4e6e360b2ce9816dcca29396571dda1c6027d/security/functions/checkSecurity.js > functions/checkSecurity.js
20+
21+
- uses: stoplightio/spectral-action@v0.8.13

.gitignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
app.log
2-
publiccode-validator
1+
dist/
2+
tmp/
3+
.idea/
4+
.vscode
5+
6+
# Compiled binary
7+
/publiccode-validator-api

.golangci.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
version: "2"
2+
run:
3+
# If set, we pass it to "go list -mod={option}". From "go help modules":
4+
# If invoked with -mod=readonly, the go command is disallowed from the implicit
5+
# automatic updating of go.mod described above. Instead, it fails when any changes
6+
# to go.mod are needed. This setting is most useful to check that go.mod does
7+
# not need updates, such as in a continuous integration and testing system.
8+
# If invoked with -mod=vendor, the go command assumes that the vendor
9+
# directory holds the correct copies of dependencies and ignores
10+
# the dependency descriptions in go.mod.
11+
#
12+
# Allowed values: readonly|vendor|mod
13+
# Default: ""
14+
modules-download-mode: readonly
15+
16+
# Include test files or not.
17+
# Default: true
18+
tests: false
19+
20+
linters:
21+
default: all
22+
23+
disable:
24+
# We don't want to limit dependencies
25+
- depguard
26+
# Not terribly useful and ends up in too much boilerplate
27+
- exhaustruct
28+
29+
# Not useful
30+
- depguard
31+
# Not terribly useful and ends up in too much boilerplate
32+
- exhaustruct
33+
34+
# Seems excessive
35+
- tagalign
36+
37+
# More false positive than actual issues
38+
- mnd
39+
40+
- noinlineerr
41+
# Annyoing sometimes
42+
- revive
43+
44+
settings:
45+
wrapcheck:
46+
ignore-sigs:
47+
# Fiber takes care of unwrapping the error
48+
- func (*github.com/gofiber/fiber/v2.Ctx)
49+
50+
# No point in wrapping these
51+
- func encoding/json.Marshal(v any)
52+
- func encoding/json.UnmarshalJSON(v any)
53+
54+
# Defaults
55+
- .Errorf(
56+
- errors.New(
57+
- errors.Unwrap(
58+
- .Wrap(
59+
- .Wrapf(
60+
- .WithMessage(
61+
- .WithMessagef(
62+
- .WithStack(
63+
funlen:
64+
# Increase the number of lines, considering funlen counts comments as well
65+
# (https://github.com/ultraware/funlen/issues/12)
66+
#
67+
# default: 60
68+
lines: 80
69+
usetesting:
70+
context-background: true
71+
context-todo: true
72+
os-chdir: true
73+
os-mkdir-temp: true
74+
os-setenv: true
75+
os-create-temp: true
76+
os-temp-dir: false
77+
78+
exclusions:
79+
generated: lax
80+
presets:
81+
- comments
82+
- common-false-positives
83+
- legacy
84+
- std-error-handling
85+
paths:
86+
- third_party$
87+
- builtin$
88+
- examples$
89+
90+
formatters:
91+
enable:
92+
- gci
93+
- gofmt
94+
- gofumpt
95+
- goimports
96+
97+
exclusions:
98+
generated: lax
99+
paths:
100+
- third_party$
101+
- builtin$
102+
- examples$ # fast: true

.goreleaser.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
before:
4+
hooks:
5+
# You may remove this if you don't use go modules.
6+
- go mod tidy
7+
# you may remove this if you don't need go generate
8+
- go generate ./...
9+
builds:
10+
- env:
11+
- CGO_ENABLED=0
12+
ldflags:
13+
- -s -w
14+
goos:
15+
- linux
16+
archives:
17+
- replacements:
18+
darwin: Darwin
19+
linux: Linux
20+
windows: Windows
21+
386: i386
22+
amd64: x86_64
23+
checksum:
24+
name_template: "checksums.txt"
25+
snapshot:
26+
name_template: "{{ incpatch .Version }}-next"
27+
changelog:
28+
sort: asc
29+
filters:
30+
exclude:
31+
- "^docs:"
32+
- "^test:"
33+
dockers:
34+
- dockerfile: Dockerfile.goreleaser
35+
image_templates:
36+
- "ghcr.io/italia/publiccode-validator-api:{{ .Tag }}"
37+
- "ghcr.io/italia/publiccode-validator-api:latest"

.goreleaser.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)