Skip to content

Commit 4424e7e

Browse files
authored
Added downstreams action (#141)
1 parent 3331a53 commit 4424e7e

File tree

16 files changed

+616
-2
lines changed

16 files changed

+616
-2
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release downstreams
2+
3+
on:
4+
push:
5+
tags:
6+
- 'downstreams/v*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Setup Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: 1.21
21+
22+
- name: Build
23+
run: /bin/bash .github/workflows/build.sh downstreams
24+
25+
- name: Compress
26+
run: /bin/bash .github/workflows/compress.sh
27+
28+
- name: Create release
29+
uses: softprops/action-gh-release@v1
30+
with:
31+
files: dist/*

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
acceptance @nfx
1010
database-diagram-builder @alexott
11+
downstreams @nfx
1112
go-libs @nfx
1213
ip_access_list_analyzer @alexott
1314
metascan @nfx

acceptance/boilerplate/actions.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type Boilerplate struct {
4040
context *githubactions.GitHubContext
4141
GitHub *github.GitHubClient
4242
uploader *artifactUploader
43+
ExtraTag string
4344
}
4445

4546
func (a *Boilerplate) PrepareArtifacts() (string, error) {
@@ -134,7 +135,7 @@ func (a *Boilerplate) CreateOrCommentOnIssue(ctx context.Context, newIssue githu
134135
func (a *Boilerplate) tag() string {
135136
// The ref path to the workflow. For example,
136137
// octocat/hello-world/.github/workflows/my-workflow.yml@refs/heads/my_branch.
137-
return fmt.Sprintf("\n<!-- workflow:%s -->", a.Action.Getenv("GITHUB_WORKFLOW_REF"))
138+
return fmt.Sprintf("\n<!-- workflow:%s %s -->", a.Action.Getenv("GITHUB_WORKFLOW_REF"), a.ExtraTag)
138139
}
139140

140141
func (a *Boilerplate) taggedComment(ctx context.Context, body string) (string, error) {

acceptance/ecosystem/python.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
"github.com/databricks/databricks-sdk-go/logger"
2323
"github.com/databrickslabs/sandbox/acceptance/redaction"
24-
"github.com/databrickslabs/sandbox/acceptance/toolchain"
24+
"github.com/databrickslabs/sandbox/go-libs/toolchain"
2525
"github.com/databrickslabs/sandbox/go-libs/env"
2626
"github.com/databrickslabs/sandbox/go-libs/fileset"
2727
"github.com/databrickslabs/sandbox/go-libs/process"

downstreams/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
downstreams

downstreams/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
default: build
2+
3+
fmt: lint
4+
@echo "✓ Formatting source code with goimports ..."
5+
@goimports -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
6+
@echo "✓ Formatting source code with gofmt ..."
7+
@gofmt -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
8+
9+
lint: vendor
10+
@echo "✓ Linting source code with https://staticcheck.io/ ..."
11+
@staticcheck ./...
12+
13+
test:
14+
@echo "✓ Running tests ..."
15+
@gotestsum --format pkgname-and-test-fails --no-summary=skipped --raw-command go test -v -json -short -coverprofile=coverage.txt ./...
16+
17+
coverage: test
18+
@echo "✓ Opening coverage for unit tests ..."
19+
@go tool cover -html=coverage.txt
20+
21+
vendor:
22+
@echo "✓ Filling vendor folder with library code ..."
23+
@go mod vendor
24+
25+
.PHONY: build vendor coverage test lint fmt

downstreams/README.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
title: "Reverse dependabot"
3+
language: go
4+
author: "Serge Smertin"
5+
date: 2024-03-30
6+
7+
tags:
8+
- github
9+
- testing
10+
---
11+
12+
# Downstream dependency backwards compatibility enforcer
13+
14+
15+
- [Downstream dependency backwards compatibility enforcer](#downstream-dependency-backwards-compatibility-enforcer)
16+
- [Usage](#usage)
17+
- [Logs](#logs)
18+
- [Releasing](#releasing)
19+
20+
Executes tests of a dependent project and provide a report
21+
22+
## Usage
23+
24+
Add to your `.github/workflows` folder:
25+
26+
```yaml
27+
name: downstreams
28+
29+
on:
30+
pull_request:
31+
types: [opened, synchronize]
32+
merge_group:
33+
types: [checks_requested]
34+
push:
35+
# Always run on push to main. The build cache can only be reused
36+
# if it was saved by a run from the repository's default branch.
37+
# The run result will be identical to that from the merge queue
38+
# because the commit is identical, yet we need to perform it to
39+
# seed the build cache.
40+
branches:
41+
- main
42+
43+
permissions:
44+
id-token: write
45+
contents: read
46+
pull-requests: write
47+
48+
jobs:
49+
ci:
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
downstream:
54+
- name: ucx
55+
- name: lsql
56+
- name: remorph
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@v3
61+
with:
62+
fetch-depth: 0
63+
64+
- name: Install Python
65+
uses: actions/setup-python@v4
66+
with:
67+
cache: 'pip'
68+
cache-dependency-path: '**/pyproject.toml'
69+
python-version: 3.10
70+
71+
- name: Install toolchain
72+
run: |
73+
pip install hatch==1.9.4
74+
75+
- name: Acceptance
76+
uses: databrickslabs/sandbox/downstreams@downstreams/v0.0.1
77+
with:
78+
repo: ${{ matrix.downstream.name }}
79+
org: databrickslabs
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
```
83+
84+
## Logs
85+
86+
If you use `github.com/databrickslabs/sandbox/go-libs/fixtures`, the logs would be available in `go-slog.json` artifact:
87+
88+
```go
89+
import (
90+
"testing"
91+
"github.com/databrickslabs/sandbox/go-libs/fixtures"
92+
)
93+
94+
func TestShowDatabases(t *testing.T) {
95+
ctx, w := fixtures.WorkspaceTest(t)
96+
// ...
97+
}
98+
```
99+
100+
## Releasing
101+
102+
As long as https://github.com/databrickslabs/sandbox is a monorepo, the `acceptance` action has to get a two-step release process:
103+
104+
1. NodeJS shim - edit version file in `shim.js` to pick `v0.0.1` as version in the top of the file.
105+
2. Go module - `git tag acceptance/v0.0.1` and wait till https://github.com/databrickslabs/sandbox/actions/workflows/acceptance-release.yml is complete.
106+
107+
Tag names must start with `acceptance/` in order for [acceptance-release](../.github/workflows/acceptance-release.yml) to trigger and this folder to be used as Go module.

downstreams/action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: 'Check downstream dependencies'
3+
description: 'Re-runs unit tests over downstream dependencies'
4+
author: Serge Smertin
5+
inputs:
6+
org:
7+
description: 'GitHub Organization'
8+
default: databrickslabs
9+
required: true
10+
repo:
11+
description: 'GitHub Repository'
12+
required: true
13+
14+
runs:
15+
using: node20
16+
main: shim.js

downstreams/go.mod

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module github.com/databrickslabs/sandbox/downstreams
2+
3+
go 1.21.0
4+
5+
require github.com/databrickslabs/sandbox/acceptance v0.2.1
6+
7+
require (
8+
cloud.google.com/go/compute v1.24.0 // indirect
9+
cloud.google.com/go/compute/metadata v0.2.3 // indirect
10+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 // indirect
11+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect
12+
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.0 // indirect
13+
github.com/databricks/databricks-sdk-go v0.33.0 // indirect
14+
github.com/databrickslabs/sandbox/go-libs v0.2.0 // indirect
15+
github.com/felixge/httpsnoop v1.0.4 // indirect
16+
github.com/go-logr/logr v1.4.1 // indirect
17+
github.com/go-logr/stdr v1.2.2 // indirect
18+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
19+
github.com/golang/protobuf v1.5.3 // indirect
20+
github.com/google/go-querystring v1.1.0 // indirect
21+
github.com/google/s2a-go v0.1.7 // indirect
22+
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
23+
github.com/sethvargo/go-githubactions v1.2.0 // indirect
24+
go.opencensus.io v0.24.0 // indirect
25+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0 // indirect
26+
go.opentelemetry.io/otel v1.23.1 // indirect
27+
go.opentelemetry.io/otel/metric v1.23.1 // indirect
28+
go.opentelemetry.io/otel/trace v1.23.1 // indirect
29+
golang.org/x/crypto v0.19.0 // indirect
30+
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
31+
golang.org/x/mod v0.15.0 // indirect
32+
golang.org/x/net v0.21.0 // indirect
33+
golang.org/x/oauth2 v0.17.0 // indirect
34+
golang.org/x/sys v0.17.0 // indirect
35+
golang.org/x/text v0.14.0 // indirect
36+
golang.org/x/time v0.5.0 // indirect
37+
google.golang.org/api v0.166.0 // indirect
38+
google.golang.org/appengine v1.6.8 // indirect
39+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect
40+
google.golang.org/grpc v1.62.0 // indirect
41+
google.golang.org/protobuf v1.32.0 // indirect
42+
gopkg.in/ini.v1 v1.67.0 // indirect
43+
)

0 commit comments

Comments
 (0)