Skip to content

Commit

Permalink
Merge pull request #1 from gofiber/update
Browse files Browse the repository at this point in the history
Add GitHub Workflows, and Updates to Module
  • Loading branch information
gaby authored Sep 15, 2024
2 parents e15a0a6 + 9ea6d85 commit a3bbfab
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 103 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @gofiber/maintainers
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod"
directory: "/" # Location of package manifests
labels:
- "🤖 Dependencies"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
labels:
- "🤖 Dependencies"
111 changes: 111 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
on:
push:
branches:
- master
- main
paths-ignore:
- "**/*.md"
pull_request:
paths-ignore:
- "**/*.md"

permissions:
# deployments permission to deploy GitHub pages website
deployments: write
# contents permission to update benchmark contents in gh-pages branch
contents: write
# allow posting comments to pull request
pull-requests: write

name: Benchmark
jobs:
Compare:
runs-on: ubuntu-latest
steps:
- name: Fetch Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # to be able to retrieve the last commit in main

- name: Install Go
uses: actions/setup-go@v5
with:
# NOTE: Keep this in sync with the version from go.mod
go-version: "1.22.x"

- name: Run Benchmark
run: set -o pipefail; go test ./... -benchmem -run=^$ -bench . | tee output.txt

# NOTE: Benchmarks could change with different CPU types
- name: Get GitHub Runner System Information
uses: kenchan0130/[email protected]
id: system-info

- name: Get Main branch SHA
id: get-main-branch-sha
run: |
SHA=$(git rev-parse origin/main)
echo "sha=$SHA" >> $GITHUB_OUTPUT
- name: Get Benchmark Results from main branch
id: cache
uses: actions/cache/restore@v4
with:
path: ./cache
key: ${{ steps.get-main-branch-sha.outputs.sha }}-${{ runner.os }}-${{ steps.system-info.outputs.cpu-model }}-benchmark

# This will only run if we have Benchmark Results from main branch
- name: Compare PR Benchmark Results with main branch
uses: benchmark-action/[email protected]
if: steps.cache.outputs.cache-hit == 'true'
with:
tool: 'go'
output-file-path: output.txt
external-data-json-path: ./cache/benchmark-data.json
# Do not save the data (This allows comparing benchmarks)
save-data-file: false
fail-on-alert: true
# Comment on the PR if the branch is not a fork
comment-on-alert: ${{ github.event.pull_request.head.repo.fork == false }}
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-always: true
alert-threshold: "150%"

- name: Store Benchmark Results for main branch
uses: benchmark-action/[email protected]
if: ${{ github.ref_name == 'main' }}
with:
tool: 'go'
output-file-path: output.txt
external-data-json-path: ./cache/benchmark-data.json
# Save the data to external file (cache)
save-data-file: true
fail-on-alert: false
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-always: true
alert-threshold: "150%"

- name: Publish Benchmark Results to GitHub Pages
uses: benchmark-action/[email protected]
if: ${{ github.ref_name == 'main' }}
with:
tool: 'go'
output-file-path: output.txt
benchmark-data-dir-path: "benchmarks"
fail-on-alert: false
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-on-alert: true
summary-always: true
# Save the data to external file (GitHub Pages)
save-data-file: true
alert-threshold: "150%"
# TODO: reactivate it later -> when v3 is the stable one
#auto-push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
auto-push: false

- name: Update Benchmark Results cache
uses: actions/cache/save@v4
if: ${{ github.ref_name == 'main' }}
with:
path: ./cache
key: ${{ steps.get-main-branch-sha.outputs.sha }}-${{ runner.os }}-${{ steps.system-info.outputs.cpu-model }}-benchmark
40 changes: 40 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Adapted from https://github.com/golangci/golangci-lint-action/blob/b56f6f529003f1c81d4d759be6bd5f10bf9a0fa0/README.md#how-to-use

name: golangci-lint
on:
push:
branches:
- master
- main
paths-ignore:
- "**/*.md"
pull_request:
paths-ignore:
- "**/*.md"

permissions:
# Required: allow read access to the content for analysis.
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
# Optional: Allow write access to checks to allow the action to annotate code in the PR.
checks: write

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
# NOTE: Keep this in sync with the version from go.mod
go-version: "1.22.x"
cache: false

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
# NOTE: Keep this in sync with the version from .golangci.yml
version: v1.60.3
37 changes: 0 additions & 37 deletions .github/workflows/security.yml

This file was deleted.

57 changes: 38 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,54 @@
name: Test

on:
push:
branches:
- master
- main
paths-ignore:
- "**/*.md"
pull_request:
branches:
- main
permissions:
contents: read
paths-ignore:
- "**/*.md"

jobs:
unit:
strategy:
matrix:
go: ['1.20','1.21']
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: true
runs-on: ${{ matrix.os }}
go-version: [1.22.x, 1.23.x]
platform: [ubuntu-latest, windows-latest, macos-latest, macos-13]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Fetch Repository
uses: actions/checkout@v4

- name: Setup Go ${{ matrix.go }}
uses: actions/setup-go@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: false
go-version: ${{ matrix.go-version }}

- name: Run Tests
run: go test -race -cover -coverprofile=coverage -covermode=atomic -v ./...
- name: Test
run: go run gotest.tools/gotestsum@latest -f testname -- ./... -race -count=1 -coverprofile=coverage.txt -covermode=atomic -shuffle=on

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
- name: Upload coverage reports to Codecov
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.go-version == '1.23.x' }}
uses: codecov/[email protected]
with:
files: ./coverage
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
flags: unittests
slug: gofiber/schema

repeated:
runs-on: ubuntu-latest
steps:
- name: Fetch Repository
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: stable

- name: Test
run: go run gotest.tools/gotestsum@latest -f testname -- ./... -race -count=15 -shuffle=on
32 changes: 0 additions & 32 deletions .github/workflows/verify.yml

This file was deleted.

12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# gorilla/schema
# gofiber/schema

![testing](https://github.com/gorilla/schema/actions/workflows/test.yml/badge.svg)
[![codecov](https://codecov.io/github/gorilla/schema/branch/main/graph/badge.svg)](https://codecov.io/github/gorilla/schema)
[![godoc](https://godoc.org/github.com/gorilla/schema?status.svg)](https://godoc.org/github.com/gorilla/schema)
[![sourcegraph](https://sourcegraph.com/github.com/gorilla/schema/-/badge.svg)](https://sourcegraph.com/github.com/gorilla/schema?badge)


![Gorilla Logo](https://github.com/gorilla/.github/assets/53367916/d92caabf-98e0-473e-bfbf-ab554ba435e5)

Package gorilla/schema converts structs to and from form values.
Package gofiber/schema converts structs to and from form values.

## Example

Expand Down
4 changes: 2 additions & 2 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func (d *Decoder) decode(v reflect.Value, path string, parts []pathPart, values
} else if m.IsValid {
u := reflect.New(elemT)
if m.IsSliceElementPtr {
u = reflect.New(reflect.PtrTo(elemT).Elem())
u = reflect.New(reflect.PointerTo(elemT).Elem())
}
if err := u.Interface().(encoding.TextUnmarshaler).UnmarshalText([]byte(value)); err != nil {
return ConversionError{
Expand Down Expand Up @@ -513,7 +513,7 @@ func isTextUnmarshaler(v reflect.Value) unmarshaler {
// encoding.TextUnmarshaler
m.IsSliceElement = true
if t = t.Elem(); t.Kind() == reflect.Ptr {
t = reflect.PtrTo(t.Elem())
t = reflect.PointerTo(t.Elem())
v = reflect.Zero(t)
m.IsSliceElementPtr = true
m.Unmarshaler, m.IsValid = v.Interface().(encoding.TextUnmarshaler)
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.

/*
Package gorilla/schema fills a struct with form values.
Package gofiber/schema fills a struct with form values.
The basic usage is really simple. Given this struct:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/gorilla/schema
module github.com/gofiber/schema

go 1.20
go 1.22

0 comments on commit a3bbfab

Please sign in to comment.