Skip to content

Commit

Permalink
init newman (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
matoszz authored Sep 3, 2024
1 parent 59e62a4 commit fd99f91
Show file tree
Hide file tree
Showing 76 changed files with 5,687 additions and 2 deletions.
24 changes: 24 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
env:
APP_NAME: ${BUILDKITE_PIPELINE_SLUG}
IMAGE_REPO: ghcr.io/theopenlane/${APP_NAME}
SONAR_HOST: "https://sonarcloud.io"
steps:
- group: ":test_tube: Tests"
key: "tests"
steps:
- label: ":golangci-lint: lint :lint-roller:"
key: "lint"
cancel_on_build_failing: true
plugins:
- docker#v5.11.0:
image: "ghcr.io/theopenlane/build-image:latest"
always-pull: true
command: ["task", "go:lint"]
environment:
- "GOTOOLCHAIN=auto"
- docker#v5.11.0:
image: "ghcr.io/theopenlane/build-image:latest"
always-pull: true
command: ["task", "go:test"]
environment:
- "GOTOOLCHAIN=auto"
23 changes: 23 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Contributing

Please read the [contributing](.github/CONTRIBUTING.md) guide as well as the [Developer Certificate of Origin](https://developercertificate.org/). You will be required to sign all commits to the OpenLane project, so if you're unfamiliar with how to set that up, see [github's documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification).

Given external users will not have write to the branches in this repository, you'll need to follow the forking process to open a PR - [here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) is a guide from github on how to do so.

## Licensing

This repository contains open source software that comprises the OpenLane stack which is open source software under [Apache 2.0](LICENSE). OpenLane's SaaS / Cloud Services are products produced from this open source software exclusively by OpenLane Technology, Inc. This product is produced under our published commercial terms (which are subject to change). Any logos or trademarks in our repositories in [theopenlane](https://github.com/theopenlane) organization are not covered under the Apache License and are trademarks of OpenLane Technology, Inc.

Others are allowed to make their own distribution of this software or include this software in other commercial offerings, but cannot use any of the OpenLane logos, trademarks, cloud services, etc.

## Security

We take the security of our software products and services seriously, including our commercial services and all of the open source code repositories managed through our Github Organizations, such as [theopenlane](https://github.com/theopenlane). If you believe you have found a security vulnerability in any of our repositories or in our SaaS offering(s), please report it to us through coordinated disclosure.

**Please do NOT report security vulnerabilities through public github issues, discussions, or pull requests!**

Instead, please send an email to `security@theopenlane.io` with as much information as possible to best help us understand and resolve the issues. See the security policy attached to this repository for more details.

## Questions?

You can email us at `info@theopenlane.io`, open a github issue in this repository, or reach out to [matoszz](https://github.com/matoszz) directly.
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Bug report
about: Create a report to help us improve
title: "[Bug]"
labels: bug
assignees: ''

---

**Describe the bug or issue you're encountering**


**What are the relevant steps to reproduce, including the version(s) of the relevant software?**


**What is the expected behavior?**
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[Feature Request]"
labels: enhancement
assignees: matoszz

---

**Describe how the feature might make your life easier or solve a problem**

**Describe the solution you'd like to see with any relevant context**

**Describe any alternatives you've considered or if there are short-tern vs. long-term options**
21 changes: 21 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add 'bug' label to any PR where the head branch name starts with `bug` or has a `bug` section in the name
bug:
- head-branch: ["^bug", "bug"]
# Add 'enhancement' label to any PR where the head branch name starts with `enhancement` or has a `enhancement` section in the name
enhancement:
- head-branch: ["^enhancement", "enhancement", "^feature", "feature", "^enhance", "enhance", "^feat", "feat"]
# Add 'breaking-change' label to any PR where the head branch name starts with `breaking-change` or has a `breaking-change` section in the name
breaking-change:
- head-branch: ["^breaking-change", "breaking-change"]
ci:
- changed-files:
- any-glob-to-any-file: .github/**
- any-glob-to-any-file: .buildkite/**
local-development:
- changed-files:
- any-glob-to-any-file: scripts/**
- any-glob-to-any-file: Taskfile.yaml
- any-glob-to-any-file: docker/**
cli:
- changed-files:
- any-glob-to-any-file: cmd/**
24 changes: 24 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
changelog:
exclude:
labels:
- ignore-for-release
authors: []
categories:
- title: Breaking Changes 🛠
labels:
- Semver-Major
- breaking-change
- title: New Features 🎉
labels:
- Semver-Minor
- enhancement
- feature
- title: Bug Fixes 🐛
labels:
- bug
- title: 👒 Dependencies
labels:
- dependencies
- title: Other Changes
labels:
- "*"
13 changes: 13 additions & 0 deletions .github/workflows/labeler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Pull Request Labeler"
on:
- pull_request_target
jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
with:
sync-labels: true
127 changes: 127 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Release
on:
workflow_dispatch:
release:
types: [created]
permissions:
contents: write
jobs:
ldflags_args:
runs-on: ubuntu-latest
outputs:
commit-date: ${{ steps.ldflags.outputs.commit-date }}
commit: ${{ steps.ldflags.outputs.commit }}
version: ${{ steps.ldflags.outputs.version }}
tree-state: ${{ steps.ldflags.outputs.tree-state }}
steps:
- id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- id: ldflags
run: |
echo "commit=$GITHUB_SHA" >> $GITHUB_OUTPUT
echo "commit-date=$(git log --date=iso8601-strict -1 --pretty=%ct)" >> $GITHUB_OUTPUT
echo "version=$(git describe --tags --always --dirty | cut -c2-)" >> $GITHUB_OUTPUT
echo "tree-state=$(if git diff --quiet; then echo "clean"; else echo "dirty"; fi)" >> $GITHUB_OUTPUT
release:
name: Build and release
needs:
- ldflags_args
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
permissions:
contents: write # To add assets to a release.
id-token: write # To do keyless signing with cosign
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Install Syft
uses: anchore/sbom-action/download-syft@ab9d16d4b419c9d1a02df5213fa0ebe965ca5a57 # v0.17.1
- name: Install Cosign
uses: sigstore/cosign-installer@v3.6.0
- name: Run GoReleaser
id: run-goreleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
VERSION: ${{ needs.ldflags_args.outputs.version }}
COMMIT: ${{ needs.ldflags_args.outputs.commit }}
COMMIT_DATE: ${{ needs.ldflags_args.outputs.commit-date }}
TREE_STATE: ${{ needs.ldflags_args.outputs.tree-state }}
- name: Generate subject
id: hash
env:
ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}"
run: |
set -euo pipefail
hashes=$(echo $ARTIFACTS | jq --raw-output '.[] | {name, "digest": (.extra.Digest // .extra.Checksum)} | select(.digest) | {digest} + {name} | join(" ") | sub("^sha256:";"")' | base64 -w0)
if test "$hashes" = ""; then # goreleaser < v1.13.0
checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path')
hashes=$(cat $checksum_file | base64 -w0)
fi
echo "hashes=$hashes" >> $GITHUB_OUTPUT
provenance:
name: Generate provenance (SLSA3)
needs:
- release
permissions:
actions: read # To read the workflow path.
id-token: write # To sign the provenance.
contents: write # To add assets to a release.
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
with:
base64-subjects: "${{ needs.release.outputs.hashes }}"
upload-assets: true # upload to a new release
verification:
name: Verify provenance of assets (SLSA3)
needs:
- release
- provenance
runs-on: ubuntu-latest
permissions: read-all
steps:
- name: Install the SLSA verifier
uses: slsa-framework/slsa-verifier/actions/installer@v2.6.0
- name: Download assets
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CHECKSUMS: "${{ needs.release.outputs.hashes }}"
ATT_FILE_NAME: "${{ needs.provenance.outputs.provenance-name }}"
run: |
set -euo pipefail
checksums=$(echo "$CHECKSUMS" | base64 -d)
while read -r line; do
fn=$(echo $line | cut -d ' ' -f2)
echo "Downloading $fn"
gh -R "$GITHUB_REPOSITORY" release download "$GITHUB_REF_NAME" -p "$fn"
done <<<"$checksums"
gh -R "$GITHUB_REPOSITORY" release download "$GITHUB_REF_NAME" -p "$ATT_FILE_NAME"
- name: Verify assets
env:
CHECKSUMS: "${{ needs.release.outputs.hashes }}"
PROVENANCE: "${{ needs.provenance.outputs.provenance-name }}"
run: |-
set -euo pipefail
checksums=$(echo "$CHECKSUMS" | base64 -d)
while read -r line; do
fn=$(echo $line | cut -d ' ' -f2)
echo "Verifying SLSA provenance for $fn"
slsa-verifier verify-artifact --provenance-path "$PROVENANCE" \
--source-uri "github.com/$GITHUB_REPOSITORY" \
--source-tag "$GITHUB_REF_NAME" \
"$fn"
done <<<"$checksums"
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
*.exe
*.exe~
*.dll
*.so
*.dylib

*.test

*.out

go.work

*.db
server.crt
server.key
private_key.pem
public_key.pem

*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar

*.log

.vscode

.DS_Store*
.AppleDouble
.LSOverride
ehthumbs.db
Icon?
Thumbs.db

*.mime
*.mim

*.env
*.env-dev
*.config.yaml
44 changes: 44 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
run:
timeout: 10m
allow-serial-runners: true
concurrency: 0
linters-settings:
goimports:
local-prefixes: github.com/theopenlane/newman
gofumpt:
extra-rules: true
gosec:
exclude-generated: true
revive:
ignore-generated-header: true
linters:
enable:
- bodyclose
- errcheck
- gocritic
- gocyclo
- err113
- gofmt
- goimports
- mnd
- gosimple
- govet
- gosec
- ineffassign
- misspell
- noctx
- revive
- staticcheck
- stylecheck
- typecheck
- unused
- whitespace
- wsl
issues:
fix: true
exclude-use-default: true
exclude-dirs:
- .buildkite/*
- .github/*
- docker/*
exclude-files: []
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
default_stages: [pre-commit]
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: detect-private-key
exclude: providers/gmail/gmail_test.go
- repo: https://github.com/google/yamlfmt
rev: v0.13.0
hooks:
- id: yamlfmt
- repo: https://github.com/crate-ci/typos
rev: typos-dict-v0.11.27
hooks:
- id: typos
20 changes: 20 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[files]
extend-exclude = ["go.mod","go.sum","providers/smtp/smtp_test.go"]
ignore-hidden = true
ignore-files = true
ignore-dot = true
ignore-vcs = true
ignore-global = true
ignore-parent = true

[default]
binary = false
check-filename = true
check-file = true
unicode = true
ignore-hex = true
identifier-leading-digits = false
locale = "en"
extend-ignore-identifiers-re = []
extend-ignore-words-re = ["(?i)requestor","(?i)indentity","(?i)encrypter","(?i)seeked","(?i)generater"]
extend-ignore-re = ["#\\s*spellchecker:off\\s*\\n.*\\n\\s*#\\s*spellchecker:on"]
Loading

0 comments on commit fd99f91

Please sign in to comment.