Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added downstreams action #141

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/downstreams-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release downstreams

on:
push:
tags:
- 'downstreams/v*'

jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: Build
run: /bin/bash .github/workflows/build.sh downstreams

- name: Compress
run: /bin/bash .github/workflows/compress.sh

- name: Create release
uses: softprops/action-gh-release@v1
with:
files: dist/*
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

acceptance @nfx
database-diagram-builder @alexott
downstreams @nfx
go-libs @nfx
ip_access_list_analyzer @alexott
metascan @nfx
Expand Down
3 changes: 2 additions & 1 deletion acceptance/boilerplate/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type Boilerplate struct {
context *githubactions.GitHubContext
GitHub *github.GitHubClient
uploader *artifactUploader
ExtraTag string
}

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

func (a *Boilerplate) taggedComment(ctx context.Context, body string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion acceptance/ecosystem/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/databricks/databricks-sdk-go/logger"
"github.com/databrickslabs/sandbox/acceptance/redaction"
"github.com/databrickslabs/sandbox/acceptance/toolchain"
"github.com/databrickslabs/sandbox/go-libs/toolchain"
"github.com/databrickslabs/sandbox/go-libs/env"
"github.com/databrickslabs/sandbox/go-libs/fileset"
"github.com/databrickslabs/sandbox/go-libs/process"
Expand Down
1 change: 1 addition & 0 deletions downstreams/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
downstreams
25 changes: 25 additions & 0 deletions downstreams/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
default: build

fmt: lint
@echo "✓ Formatting source code with goimports ..."
@goimports -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
@echo "✓ Formatting source code with gofmt ..."
@gofmt -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")

lint: vendor
@echo "✓ Linting source code with https://staticcheck.io/ ..."
@staticcheck ./...

test:
@echo "✓ Running tests ..."
@gotestsum --format pkgname-and-test-fails --no-summary=skipped --raw-command go test -v -json -short -coverprofile=coverage.txt ./...

coverage: test
@echo "✓ Opening coverage for unit tests ..."
@go tool cover -html=coverage.txt

vendor:
@echo "✓ Filling vendor folder with library code ..."
@go mod vendor

.PHONY: build vendor coverage test lint fmt
107 changes: 107 additions & 0 deletions downstreams/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: "Reverse dependabot"
language: go
author: "Serge Smertin"
date: 2024-03-30

tags:
- github
- testing
---

# Downstream dependency backwards compatibility enforcer


- [Downstream dependency backwards compatibility enforcer](#downstream-dependency-backwards-compatibility-enforcer)
- [Usage](#usage)
- [Logs](#logs)
- [Releasing](#releasing)

Executes tests of a dependent project and provide a report

## Usage

Add to your `.github/workflows` folder:

```yaml
name: downstreams

on:
pull_request:
types: [opened, synchronize]
merge_group:
types: [checks_requested]
push:
# Always run on push to main. The build cache can only be reused
# if it was saved by a run from the repository's default branch.
# The run result will be identical to that from the merge queue
# because the commit is identical, yet we need to perform it to
# seed the build cache.
branches:
- main

permissions:
id-token: write
contents: read
pull-requests: write

jobs:
ci:
strategy:
fail-fast: false
matrix:
downstream:
- name: ucx
- name: lsql
- name: remorph
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Python
uses: actions/setup-python@v4
with:
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
python-version: 3.10

- name: Install toolchain
run: |
pip install hatch==1.9.4

- name: Acceptance
uses: databrickslabs/sandbox/downstreams@downstreams/v0.0.1
with:
repo: ${{ matrix.downstream.name }}
org: databrickslabs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

## Logs

If you use `github.com/databrickslabs/sandbox/go-libs/fixtures`, the logs would be available in `go-slog.json` artifact:

```go
import (
"testing"
"github.com/databrickslabs/sandbox/go-libs/fixtures"
)

func TestShowDatabases(t *testing.T) {
ctx, w := fixtures.WorkspaceTest(t)
// ...
}
```

## Releasing

As long as https://github.com/databrickslabs/sandbox is a monorepo, the `acceptance` action has to get a two-step release process:

1. NodeJS shim - edit version file in `shim.js` to pick `v0.0.1` as version in the top of the file.
2. Go module - `git tag acceptance/v0.0.1` and wait till https://github.com/databrickslabs/sandbox/actions/workflows/acceptance-release.yml is complete.

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.
16 changes: 16 additions & 0 deletions downstreams/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: 'Check downstream dependencies'
description: 'Re-runs unit tests over downstream dependencies'
author: Serge Smertin
inputs:
org:
description: 'GitHub Organization'
default: databrickslabs
required: true
repo:
description: 'GitHub Repository'
required: true

runs:
using: node20
main: shim.js
43 changes: 43 additions & 0 deletions downstreams/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module github.com/databrickslabs/sandbox/downstreams

go 1.21.0

require github.com/databrickslabs/sandbox/acceptance v0.2.1

require (
cloud.google.com/go/compute v1.24.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.0 // indirect
github.com/databricks/databricks-sdk-go v0.33.0 // indirect
github.com/databrickslabs/sandbox/go-libs v0.2.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/sethvargo/go-githubactions v1.2.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0 // indirect
go.opentelemetry.io/otel v1.23.1 // indirect
go.opentelemetry.io/otel/metric v1.23.1 // indirect
go.opentelemetry.io/otel/trace v1.23.1 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.166.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect
google.golang.org/grpc v1.62.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)
Loading
Loading