Skip to content

Commit

Permalink
Merge pull request #47 from snorwin/update-actions
Browse files Browse the repository at this point in the history
Update github actions workflow
  • Loading branch information
snorwin committed Apr 16, 2024
2 parents 5f4ff9c + 140e741 commit 42d6241
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
44 changes: 28 additions & 16 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
name: Test
name: test

on:
push:
branches: [ main ]
branches:
- main
pull_request:
branches: [ main ]

permissions:
contents: read

jobs:
build:
name: Build
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ^1.15

- name: Checkout
uses: actions/checkout@v2

- name: Test
run: go test ./... -coverprofile cover.out -timeout 30m
go-version: ^1.22
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.54
test:
name: go test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ^1.22
cache: false
- name: go test
run: go test -coverprofile cover.out -timeout 30m
env:
CGO_ENABLED: 0
GO111MODULE: on
GOOS: linux
GOARCH: amd64

- name: Send coverage
- name: send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: cover.out
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# jsonpatch
[![GitHub Action](https://img.shields.io/badge/GitHub-Action-blue)](https://github.com/features/actions)
[![Documentation](https://img.shields.io/badge/godoc-reference-5272B4.svg)](https://pkg.go.dev/github.com/snorwin/jsonpatch)
[![Test](https://img.shields.io/github/workflow/status/snorwin/jsonpatch/Test?label=tests&logo=github)](https://github.com/snorwin/jsonpatch/actions)
[![Test](https://img.shields.io/github/actions/workflow/status/snorwin/jsonpatch/test.yaml?label=tests&logo=github)](https://github.com/snorwin/sonpatch/actions)
[![Go Report Card](https://goreportcard.com/badge/github.com/snorwin/jsonpatch)](https://goreportcard.com/report/github.com/snorwin/jsonpatch)
[![Coverage Status](https://coveralls.io/repos/github/snorwin/jsonpatch/badge.svg?branch=main)](https://coveralls.io/github/snorwin/jsonpatch?branch=main)
[![Releases](https://img.shields.io/github/v/release/snorwin/jsonpatch)](https://github.com/snorwin/jsonpatch/releases)
Expand Down
9 changes: 2 additions & 7 deletions patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package jsonpatch
import (
"encoding/json"
"reflect"
"slices"
)

// JSONPatch format is specified in RFC 6902
Expand Down Expand Up @@ -40,13 +41,7 @@ func (l JSONPatchList) Raw() []byte {

// List returns a copy of the underlying JSONPatch slice
func (l JSONPatchList) List() []JSONPatch {
ret := make([]JSONPatch, l.Len())

for i, patch := range l.list {
ret[i] = patch
}

return ret
return slices.Clone(l.list)
}

// CreateJSONPatch compares two JSON data structures and creates a JSONPatch according to RFC 6902
Expand Down

0 comments on commit 42d6241

Please sign in to comment.