Skip to content

Commit

Permalink
feat(psqldocker): add psqldocker package
Browse files Browse the repository at this point in the history
  • Loading branch information
bradub committed Feb 8, 2023
1 parent bbfb852 commit 452a501
Show file tree
Hide file tree
Showing 11 changed files with 975 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/codeql_psqldocker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "codeql psqldocker"

on:
push:
branches: [ main ]
paths: [ psqldocker/** ]

pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
paths: [ psqldocker/** ]

schedule:
- cron: '0 17 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

permissions:
# required for all workflows
security-events: write
# only required for workflows in private repositories
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go
- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
32 changes: 32 additions & 0 deletions .github/workflows/grype_psqldocker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: grype psqldocker

on:
push:
branches: [ main ]
paths: [ psqldocker/** ]

jobs:
scan-source:
name: Scan source code
runs-on: ubuntu-latest

permissions:
security-events: write
actions: read
contents: read

steps:
- uses: actions/checkout@v3
- uses: anchore/scan-action@v3
id: scan
with:
path: psqldocker
fail-build: true
acs-report-enable: true
severity-cutoff: medium

- name: upload Anchore scan SARIF report
if: success() || failure()
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
34 changes: 34 additions & 0 deletions .github/workflows/lint-test_psqldocker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: test-psqldocker

on:
# Trigger the workflow on push request if the files
# in ./psqltest package were modified
push:
branches:
- main
paths:
- psqldocker/**

env:
PACKAGE: psqldocker
GO_VERSION: 1.19

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout=5m -c=$GITHUB_WORKSPACE/.golangci.yml
working-directory: ./${{ env.PACKAGE }}/
21 changes: 21 additions & 0 deletions psqldocker/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Adrian Brad

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions psqldocker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.PHONY: check
lint:
golangci-lint run --fix -c=../.golangci.yml

test:
go test -mod=mod -count=1 --race ./...

test-ci:
go test -mod=mod -count=1 -timeout 60s -coverprofile=coverage.txt -covermode=atomic ./...
7 changes: 7 additions & 0 deletions psqldocker/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Package psqldocker provides functions
// to start, stop and configure a PostgreSQL docker container.
// The purpose of this package is mainly for testing.
//
// The docker container is created programatically using
// the github.com/ory/dockertest package.
package psqldocker
39 changes: 39 additions & 0 deletions psqldocker/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module github.com/purposeinplay/go-commons/psqldocker

go 1.17

require (
github.com/lib/pq v1.10.7
github.com/matryer/is v1.4.0
github.com/ory/dockertest/v3 v3.9.1
)

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/docker/cli v23.0.0+incompatible // indirect
github.com/docker/docker v23.0.0+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/runc v1.1.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/tools v0.5.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit 452a501

Please sign in to comment.