Skip to content

Commit

Permalink
feat: hand over to DT with restencil (#110)
Browse files Browse the repository at this point in the history
* feat: hand over to DT

* feat: restencil
  • Loading branch information
honzap authored Aug 30, 2024
1 parent ade48d5 commit 45e8fe0
Show file tree
Hide file tree
Showing 15 changed files with 1,625 additions and 2,176 deletions.
29 changes: 22 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
# syntax, such as anchors, will be fixed automatically.
version: 2.1
orbs:
shared: getoutreach/shared@2.24.0
shared: getoutreach/shared@2.28.1
queue: eddiewebb/[email protected]
## <<Stencil::Block(CircleCIExtraOrbs)>>

## <</Stencil::Block>>

parameters:
rebuild_cache:
type: boolean
default: false
## <<Stencil::Block(CircleCIExtraParams)>>

## <</Stencil::Block>>

# Extra contexts to expose to all jobs below
contexts: &contexts
Expand All @@ -20,6 +26,7 @@ contexts: &contexts
- confluence
- circleci-credentials
- tray-webhooks
- wizcli
## <<Stencil::Block(extraContexts)>>

## <</Stencil::Block>>
Expand Down Expand Up @@ -75,7 +82,8 @@ workflows:

release:
when:
not: << pipeline.parameters.rebuild_cache >>
and:
- not: << pipeline.parameters.rebuild_cache >>
jobs:
## <<Stencil::Block(circleWorkflowJobs)>>

Expand All @@ -95,12 +103,19 @@ workflows:
- shared/test
filters:
branches:
only: *release_branches

# Dryrun release for PRs.
- shared/release:
<<: *release
only: main
# Dryrun for PRs
- shared/pre-release: &pre-release
dryrun: true
context: *contexts
## <<Stencil::Block(circlePreReleaseDryRunExtra)>>

## <</Stencil::Block>>
requires:
## <<Stencil::Block(circlePreReleaseDryRunRequires)>>

## <</Stencil::Block>>
- shared/test
filters:
branches:
ignore: *release_branches
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# See https://help.github.com/articles/about-codeowners/
* @getoutreach/end-ades
* @getoutreach/fnd-dt

## <<Stencil::Block(customCodeowners)>>

Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# you are reducing compatibility guarantees.
## <<Stencil::Block(toolverOverride)>>
## <</Stencil::Block>>
nodejs 18.17.1
golang 1.22.6
protoc 21.5
golang 1.21.5
nodejs 20.16.0
terraform 1.5.7
# Note: Versions in this block do not override the default versions above
# but sometimes you have to declare additional versions of the same tool
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"zxh404.vscode-proto3",
"redhat.vscode-yaml",
"ms-azuretools.vscode-docker",
"foxundermoon.shell-format"
"foxundermoon.shell-format",
"WizCloud.wizcli-vscode"

// Please consider contributing back all recommended
// extensions to stencil!
Expand Down
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
// Maps the go module cache on the host to the persistent volume used by devspaces.
// These should be the respective values of `go env GOMODCACHE`.
{
"from": "${env:HOME}/.asdf/installs/golang/1.21.5/packages/pkg/mod",
"to": "/home/dev/.asdf/installs/golang/1.21.5/packages/pkg/mod"
"from": "${env:HOME}/.asdf/installs/golang/1.22.6/packages/pkg/mod",
"to": "/home/dev/.asdf/installs/golang/1.22.6/packages/pkg/mod"
},
{
// Maps the standard library location on the host to the location in the devspace.
// This enables debugging standard library code.
"from": "${env:HOME}/.asdf/installs/golang/1.21.5/go/src",
"to": "/home/dev/.asdf/installs/golang/1.21.5/go/src"
"from": "${env:HOME}/.asdf/installs/golang/1.22.6/go/src",
"to": "/home/dev/.asdf/installs/golang/1.22.6/go/src"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
APP := goql
OSS := true
_ := $(shell ./scripts/devbase.sh)
_ := $(shell ./scripts/devbase.sh)

include .bootstrap/root/Makefile

Expand Down
63 changes: 63 additions & 0 deletions cortex.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Docs: https://docs.cortex.io/docs/reference/basics/entities#service-entities

openapi: 3.0.0
info:
title: goql
description: >
A GraphQL client package written in Go.
x-cortex-type: service
x-cortex-slack:
channels:
- name: dev-tooling-design
notificationsEnabled: false
- name: dev-tooling-support
notificationsEnabled: false
- name: dt-oncall
notificationsEnabled: true
- name: fnd-dt-alerts
notificationsEnabled: true
x-cortex-owners:
- type: group
name: fnd-dt
provider: CORTEX
x-cortex-tag: goql
x-cortex-git:
github:
repository: getoutreach/goql
x-cortex-oncall:
pagerduty:
id: P9HJAUT
type: SERVICE
x-cortex-link:
## These are useful documentation links for this service. Please fill in the customLinks block if you have additional documentation links.
## name: The name of the link
## type: Choose one type from (dashboard,documentation,healthcheck,logs,metrics,runbook)
## url: The link url
## description(optional): Description to this link
- name: API Docs
type: api_documentation
url: https://engdocs.outreach.cloud/github.com/getoutreach/goql#section-readme
## <<Stencil::Block(customLinks)>>
## <</Stencil::Block>>
x-cortex-custom-metadata:
app: goql
name: goql
repo: https://github.com/getoutreach/goql
framework: stencil
language: Golang
stencil_version: v1.39.1
golang_version: 1.22.6
cli: false
service: false
product: Outreach
lifecycle: in_development
## <<Stencil::Block(extraAliases)>>
## <</Stencil::Block>>
reporting_team: fnd-dt
lintroller: bronze
x-cortex-groups:
- lifecycle:in_development
- product:Outreach
- language:Golang
- framework:stencil
- engOrg:fnd
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module github.com/getoutreach/goql

go 1.19
go 1.22

toolchain go1.22.6

require (
github.com/getoutreach/gobox v1.73.2
github.com/google/go-cmp v0.5.9
github.com/getoutreach/gobox v1.90.2
github.com/google/go-cmp v0.6.0
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0
)
11 changes: 6 additions & 5 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 0 additions & 54 deletions opslevel.yml

This file was deleted.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"license": "UNLICENSED",
"devDependencies": {
"@semantic-release/commit-analyzer": "^10.0.1",
"@semantic-release/commit-analyzer": "^12.0.0",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^9.0.3",
"@semantic-release/npm": "^10.0.4",
"@semantic-release/release-notes-generator": "^11.0.3",
"conventional-changelog-conventionalcommits": "^6.0.0",
"@semantic-release/github": "^10.0.3",
"@semantic-release/npm": "^12.0.0",
"@semantic-release/release-notes-generator": "^13.0.0",
"conventional-changelog-conventionalcommits": "^7.0.2",
"prettier": "^2.8.8",
"semantic-release": "^21.0.5",
"semver": "^7.5.2"
"semantic-release": "^23.0.8",
"semver": "^7.6.0"
}
}
79 changes: 69 additions & 10 deletions scripts/devbase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,84 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
libDir="$DIR/../.bootstrap"
lockfile="$DIR/../stencil.lock"
serviceYaml="$DIR/../service.yaml"
gojqVersion="v0.12.14"

# get_absolute_path returns the absolute path of a file
get_absolute_path() {
python="$(command -v python3 || command -v python)"
"$python" -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$1"
}

# get_field_from_yaml reads a field from a yaml file using either go-yq or python-yq
get_field_from_yaml() {
field="$1"
file="$2"
# gojq returns the path to a JIT-downloaded gojq binary.
gojq() {
set -uo pipefail

if [[ "$(yq e '.a' '-' <<<'{"a": "true"}' 2>&1)" == "true" ]]; then
# using golang version
yq e "$field" "$file"
else
# probably using python version
yq -r "$field" <"$file"
local gjDir
gjDir="${XDG_CACHE_HOME:-$HOME/.cache}/devbase/gojq"
local gojq="$gjDir/gojq-${gojqVersion}"
if [[ ! -x $gojq ]]; then
local platform arch
mkdir -p "$gjDir"
platform="$(uname -s | awk '{print tolower($0)}')"
arch="$(uname -m)"
case $arch in
x86_64)
arch=amd64
;;
aarch64)
arch=arm64
;;
esac
local basename="gojq_${gojqVersion}_${platform}_${arch}"
local ext
if [[ $platform == linux ]]; then
ext="tar.gz"
else
ext="zip"
fi
local archive="$basename.$ext"

local gojqURL="https://github.com/itchyny/gojq/releases/download/$gojqVersion/$archive"
local archivePath="$gjDir/$archive"
if [[ ! -e $archivePath ]]; then
if command -v busybox >/dev/null; then
busybox wget --quiet --output-document "$archivePath" "$gojqURL"
elif command -v wget >/dev/null; then
wget --quiet --output-document "$archivePath" "$gojqURL"
elif command -v curl >/dev/null; then
curl --fail --location --silent --output "$archivePath" "$gojqURL"
else
echo "No download tool found (looked for busybox, wget, curl)" >&2
exit 1
fi
fi

if [[ ! -e $archivePath ]]; then
echo "Failed to download gojq ($gojqURL)" >&2
exit 1
fi

if [[ $ext == "zip" ]]; then
# Explanation of flags:
# quiet, junk paths/dont make directories, extract to directory
unzip -q -j -d "$gjDir" "$archivePath" "$basename/gojq"
else
tar --strip-components=1 --directory="$gjDir" --extract --file="$archivePath" "$basename/gojq"
fi
mv "$gjDir"/gojq "$gojq"
fi

echo "$gojq"

set +uo pipefail
}

# get_field_from_yaml reads a field from a yaml file via a JIT-downloaded gojq.
get_field_from_yaml() {
local field="$1"
local file="$2"

"$(gojq)" --yaml-input -r "$field" <"$file"
}

# Use the version of devbase from stencil
Expand Down
Loading

0 comments on commit 45e8fe0

Please sign in to comment.