Skip to content

Commit

Permalink
Update build (#47)
Browse files Browse the repository at this point in the history
* Update Go to 1.23.
* Update minimum Go version to 1.21.
* Enable golangci-lint action.
* Enable dependabot.
* Pin GitHub actions to SHA sums for supply chain security.
* Fix linting issues.

Signed-off-by: SuperQ <[email protected]>
Co-authored-by: Daniel Molkentin <[email protected]>
  • Loading branch information
SuperQ and danimo authored Dec 24, 2024
1 parent 6f4ef3f commit a5729aa
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 10 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jobs:
build:
runs-on: "ubuntu-22.04"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: 1.23

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0

- name: Login to Github Packages
uses: docker/login-action@v1
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
with:
push: true
tags: ghcr.io/voc/srtrelay/srtrelay:latest

- name: Delete old containers
uses: actions/delete-package-versions@v4
uses: actions/delete-package-versions@e5bc658cc4c965c472efe991f8beea3981499c55 # v5.0.0
with:
package-name: 'srtrelay'
package-type: 'container'
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: golangci-lint
on:
push:
paths:
- "go.sum"
- "go.mod"
- "**.go"
- ".github/workflows/golangci-lint.yml"
- ".golangci.yml"
pull_request:

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
golangci:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: 1.23.x
- name: Install dependencies
run: ./scripts/install-dependencies.sh
- name: Lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
args: --verbose
version: v1.62.0
11 changes: 11 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
linters:
enable:
- goimports
- misspell

issues:
exclude-rules:
- path: _test.go
linters:
- errcheck
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ func main() {
configFlags := flag.NewFlagSet("config", flag.ContinueOnError)
configFlags.SetOutput(io.Discard)
configPath := configFlags.String("config", "config.toml", "")
configFlags.Parse(os.Args[1:])
err := configFlags.Parse(os.Args[1:])
if err != nil {
log.Fatal(err)
}

// parse config
conf, err := config.Parse([]string{*configPath, "/etc/srtrelay/config.toml"})
Expand Down
7 changes: 4 additions & 3 deletions mpegts/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ const (

// Parser object for finding the synchronization point in a MPEGTS stream
// This works as follows: parse packets until all the following have been fulfilled
// 1. Parse PAT to get PID->PMT mappings
// 2. Parse PMTs to Find PID->PES mappings
// 3. Parse PES to find H.264 SPS+PPS or equivalent
// 1. Parse PAT to get PID->PMT mappings
// 2. Parse PMTs to Find PID->PES mappings
// 3. Parse PES to find H.264 SPS+PPS or equivalent
//
// Store the original packets or generate new ones to send to a client
type Parser struct {
init [][]byte // collected packets to initialize a decoder
Expand Down

0 comments on commit a5729aa

Please sign in to comment.