-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
27 changed files
with
1,757 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# These owners will be the default owners for everything in | ||
# the repo. Unless a later match takes precedence. | ||
# By convention in @tablelandnetwork repos, the first listed | ||
# CODEOWNER is the repo DRI (directly responsible individual) | ||
* @brunocalza @avichalp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
name: Deploy | ||
|
||
concurrency: | ||
group: deploy-${{github.ref}} | ||
cancel-in-progress: true | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
release: | ||
types: | ||
- created | ||
|
||
env: | ||
GKE_REGION: us-east1 | ||
GKE_CLUSTER: basin | ||
CONTAINER_REGISTRY: us-west1-docker.pkg.dev | ||
PRIVATEKEY: ${{ secrets.PRIVATEKEY }} | ||
PROOF: ${{ secrets.PROOF }} | ||
|
||
jobs: | ||
deploy: | ||
if: github.event_name == 'release' || github.ref == 'refs/heads/main' || contains(github.event.head_commit.message, '[staging]') | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Dump GitHub context | ||
env: | ||
GITHUB_CONTEXT: ${{ toJSON(github) }} | ||
run: echo "$GITHUB_CONTEXT" | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Prepare | ||
id: prep | ||
run: | | ||
if [[ ${{ github.event_name }} == 'release' ]]; then | ||
echo "DEPLOYMENT=staging" >> "$GITHUB_ENV" | ||
else | ||
echo "DEPLOYMENT=staging" >> "$GITHUB_ENV" | ||
fi | ||
echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV" | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Buildx patch | ||
run: | | ||
Dockfiles="$(find $1 -name 'Dockerfile')" | ||
d=$(date +%s) | ||
i=0 | ||
for file in $Dockfiles; do | ||
i=$(( i + 1 )) | ||
echo "patching timestamp for $file" | ||
touch -d @$(( d + i )) "$file" | ||
done | ||
- name: Google Auth | ||
uses: 'google-github-actions/auth@v1' | ||
with: | ||
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | ||
|
||
- name: Install Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v1 | ||
with: | ||
version: 415.0.0 | ||
project_id: ${{ secrets.GCP_PROJECT }} | ||
|
||
- name: Configure Docker | ||
run: gcloud auth configure-docker $CONTAINER_REGISTRY | ||
|
||
- name: Build and push api | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./ | ||
file: ./Dockerfile | ||
builder: ${{ steps.buildx.outputs.name }} | ||
push: true | ||
tags: ${{ env.CONTAINER_REGISTRY }}/${{ secrets.GCP_PROJECT }}/textile/basin/basin_w3s:sha-${{ env.SHA_SHORT}} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
|
||
- name: Get GKE Credentials | ||
uses: 'google-github-actions/get-gke-credentials@v1' | ||
with: | ||
cluster_name: ${{ env.GKE_CLUSTER }} | ||
location: ${{ env.GKE_REGION }} | ||
|
||
- name: Deploy to GKE | ||
working-directory: ./k8s | ||
run: | | ||
DEPLOYMENT=$DEPLOYMENT IMAGE_BASIN_W3S=$CONTAINER_REGISTRY/${{ secrets.GCP_PROJECT }}/textile/basin/basin_w3s:sha-$SHA_SHORT make deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Review | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
concurrency: | ||
group: review-${{github.ref}} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
lint: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.21 | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/bin | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
~/Library/Caches/go-build | ||
%LocalAppData%\go-build | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Run linter | ||
run: make lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
concurrency: | ||
group: test-${{github.ref}} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
go-version: [1.20.x, 1.21.x] | ||
os: [ubuntu-latest] | ||
make-cmd: [test] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
~/Library/Caches/go-build | ||
%LocalAppData%\go-build | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Test | ||
run: for i in 1 2 3; do make ${{ matrix.make-cmd }} && break || (if [ $i = 3 ]; then exit -1; else sleep 1; fi ); done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
private.key | ||
proof.ucan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
linters-settings: | ||
revive: | ||
ignore-generated-header: false | ||
severity: warning | ||
confidence: 0.8 | ||
rules: | ||
- name: blank-imports | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: dot-imports | ||
- name: error-return | ||
- name: error-strings | ||
- name: error-naming | ||
- name: exported | ||
- name: if-return | ||
- name: increment-decrement | ||
- name: var-naming | ||
- name: var-declaration | ||
- name: package-comments | ||
disabled: true | ||
- name: range | ||
- name: receiver-naming | ||
- name: time-naming | ||
- name: unexported-return | ||
- name: indent-error-flow | ||
- name: errorf | ||
- name: empty-block | ||
- name: superfluous-else | ||
- name: unused-parameter | ||
- name: unreachable-code | ||
- name: redefines-builtin-id | ||
misspell: | ||
locale: US | ||
|
||
linters: | ||
enable: | ||
- revive | ||
- misspell | ||
- bodyclose | ||
- unconvert | ||
- goconst | ||
- goimports | ||
- unparam | ||
- whitespace | ||
- godot | ||
- lll | ||
- sqlclosecheck | ||
- gofumpt | ||
|
||
issues: | ||
exclude-use-default: false | ||
|
||
exclude: | ||
- stutters | ||
|
||
run: | ||
timeout: 30m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM golang:1.21.5-alpine as builder | ||
|
||
RUN apk --no-cache add make build-base git | ||
|
||
RUN mkdir /app | ||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN --mount=type=cache,target=/go/pkg/mod go mod download -x | ||
COPY . . | ||
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \ | ||
BIN_BUILD_FLAGS="GOOS=linux" make build | ||
|
||
FROM alpine | ||
|
||
COPY --from=builder /app/api /app/api | ||
WORKDIR /app | ||
ENTRYPOINT ["./api"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021-2023 Tableland Network Contributors | ||
|
||
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. |
Oops, something went wrong.