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

Configuring GH actions #3

Merged
merged 6 commits into from
Nov 29, 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
47 changes: 0 additions & 47 deletions .circleci/config.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/scripts/install-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -x
VER="20.10.19"
curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mkdir -vp ~/.docker/cli-plugins/
curl --silent -L "https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
chmod a+x ~/.docker/cli-plugins/docker-buildx
mv /tmp/docker/* /usr/bin
docker run --privileged --rm tonistiigi/binfmt --install all
67 changes: 67 additions & 0 deletions .github/workflows/test-build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: ci
permissions: read-all
on:
push:
branches: [master]
tags:
- v[0-9]+.[0-9]+.[0-9]+** # Tag filters not as strict due to different regex system on Github Actions
pull_request:

jobs:
lint:
runs-on: ubuntu-20.04
container:
image: quay.io/cortexproject/build-image:master-0ddced051
steps:
- name: Checkout Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Git safe.directory
run: |
echo "this step is needed because when running in container, actions/checkout does not set safe.directory effectively."
echo "See https://github.com/actions/runner/issues/2033. We should use --system instead of --global"
git config --system --add safe.directory $GITHUB_WORKSPACE
# Commands in the Makefile are hardcoded with an assumed file structure of the CI container
# Symlink ensures paths specified in previous commands don’t break
- name: Sym Link Expected Path to Workspace
run: |
mkdir -p /go/src/github.com/cortexproject/weaveworks-common
ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/weaveworks-common
- name: Lint
run: make lint

protos:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Sym Link Expected Path to Workspace
run: |
sudo mkdir -p /go/src/github.com/cortexproject/weaveworks-common
sudo ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/weaveworks-common
- name: Install Docker Client
run: sudo ./.github/workflows/scripts/install-docker.sh
- name: Go mod Vendor
run: go mod vendor
- name: CheckProtos
run: make check-protos

test:
runs-on: ubuntu-20.04
container:
image: quay.io/cortexproject/build-image:master-0ddced051
steps:
- name: Checkout Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Git safe.directory
run: |
echo "this step is needed because when running in container, actions/checkout does not set safe.directory effectively."
echo "See https://github.com/actions/runner/issues/2033. We should use --system instead of --global"
git config --system --add safe.directory $GITHUB_WORKSPACE
# Commands in the Makefile are hardcoded with an assumed file structure of the CI container
# Symlink ensures paths specified in previous commands don’t break
- name: Sym Link Expected Path to Workspace
run: |
mkdir -p /go/src/github.com/cortexproject/weaveworks-common
ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/weaveworks-common
- name: Test
run: make test
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ GO_FLAGS := -ldflags "-extldflags \"-static\" -linkmode=external -s -w" -tags ne
PROTOC_IMAGE=namely/protoc:1.23_0

protos:
docker run $(RM) --user $(id -u):$(id -g) -v $(shell pwd):/go/src/github.com/weaveworks/common -w /go/src/github.com/weaveworks/common $(PROTOC_IMAGE) --proto_path=/go/src/github.com/weaveworks/common --go_out=plugins=grpc:/go/src/ server/fake_server.proto
docker run $(RM) --user $(id -u):$(id -g) -v $(shell pwd):/go/src/github.com/weaveworks/common -w /go/src/github.com/weaveworks/common $(PROTOC_IMAGE) --proto_path=/go/src/github.com/weaveworks/common --go_out=plugins=grpc:/go/src/ middleware/middleware_test/echo_server.proto
docker run $(RM) --user $(id -u):$(id -g) -v $(shell pwd):/go/src/github.com/weaveworks/common -w /go/src/github.com/weaveworks/common $(PROTOC_IMAGE) -I/go/src/github.com/weaveworks/common -I/go/src/github.com/weaveworks/common/vendor/github.com/gogo/protobuf/ --proto_path=/go/src/github.com/weaveworks/common --gogofast_out=plugins=grpc:/go/src/ httpgrpc/httpgrpc.proto
docker run $(RM) --user $(id -u):$(id -g) -v $(shell pwd):/go/src/github.com/cortexproject/weaveworks-common -w /go/src/github.com/cortexproject/weaveworks-common $(PROTOC_IMAGE) --proto_path=/go/src/github.com/cortexproject/weaveworks-common --go_out=plugins=grpc:/go/src/ server/fake_server.proto
docker run $(RM) --user $(id -u):$(id -g) -v $(shell pwd):/go/src/github.com/cortexproject/weaveworks-common -w /go/src/github.com/cortexproject/weaveworks-common $(PROTOC_IMAGE) --proto_path=/go/src/github.com/cortexproject/weaveworks-common --go_out=plugins=grpc:/go/src/ middleware/middleware_test/echo_server.proto
docker run $(RM) --user $(id -u):$(id -g) -v $(shell pwd):/go/src/github.com/cortexproject/weaveworks-common -w /go/src/github.com/cortexproject/weaveworks-common $(PROTOC_IMAGE) -I/go/src/github.com/cortexproject/weaveworks-common -I/go/src/github.com/cortexproject/weaveworks-common/vendor/github.com/gogo/protobuf/ --proto_path=/go/src/github.com/cortexproject/weaveworks-common --gogofast_out=plugins=grpc:/go/src/ httpgrpc/httpgrpc.proto

protos: $(GENERATED_PROTOS)

Expand Down
11 changes: 5 additions & 6 deletions fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ package fs

import (
"io"
"io/ioutil"
"os"
"syscall"
)

// Interface is the filesystem interface type.
type Interface interface {
ReadDir(string) ([]os.FileInfo, error)
ReadDir(string) ([]os.DirEntry, error)
ReadDirNames(string) ([]string, error)
ReadDirCount(string) (int, error)
ReadFile(string) ([]byte, error)
Expand All @@ -23,8 +22,8 @@ type realFS struct{}
// FS is the way you should access the filesystem.
var fs Interface = realFS{}

func (realFS) ReadDir(path string) ([]os.FileInfo, error) {
return ioutil.ReadDir(path)
func (realFS) ReadDir(path string) ([]os.DirEntry, error) {
return os.ReadDir(path)
}

func (realFS) ReadDirNames(path string) ([]string, error) {
Expand All @@ -37,7 +36,7 @@ func (realFS) ReadDirNames(path string) ([]string, error) {
}

func (realFS) ReadFile(path string) ([]byte, error) {
return ioutil.ReadFile(path)
return os.ReadFile(path)
}

func (realFS) Lstat(path string, stat *syscall.Stat_t) error {
Expand All @@ -55,7 +54,7 @@ func (realFS) Open(path string) (io.ReadWriteCloser, error) {
// trampolines here to allow users to do fs.ReadDir etc

// ReadDir see ioutil.ReadDir
func ReadDir(path string) ([]os.FileInfo, error) {
func ReadDir(path string) ([]os.DirEntry, error) {
return fs.ReadDir(path)
}

Expand Down
56 changes: 42 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,39 +1,67 @@
module github.com/weaveworks/common

go 1.14
go 1.22

toolchain go1.23.2

require (
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
github.com/aws/aws-sdk-go v1.27.0
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/aws/aws-sdk-go v1.55.5
github.com/davecgh/go-spew v1.1.1
github.com/felixge/httpsnoop v1.0.3
github.com/go-kit/log v0.2.1
github.com/gogo/googleapis v1.1.0
github.com/gogo/protobuf v1.3.0
github.com/gogo/protobuf v1.3.2
github.com/gogo/status v1.0.3
github.com/golang/protobuf v1.5.2
github.com/golang/protobuf v1.5.4
github.com/gorilla/mux v1.7.3
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
github.com/opentracing-contrib/go-grpc v0.0.0-20180928155321-4b5a12d3ff02
github.com/opentracing-contrib/go-stdlib v0.0.0-20190519235532-cf7a6c988dc9
github.com/opentracing/opentracing-go v1.1.0
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/client_golang v1.15.1
github.com/prometheus/exporter-toolkit v0.8.2
github.com/sercand/kuberesolver/v4 v4.0.0
github.com/sirupsen/logrus v1.6.0
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/soheilhy/cmux v0.1.5
github.com/stretchr/testify v1.8.1
github.com/uber/jaeger-client-go v2.28.0+incompatible
github.com/uber/jaeger-lib v2.2.0+incompatible
github.com/weaveworks/promrus v1.2.0
go.uber.org/atomic v1.5.1 // indirect
golang.org/x/net v0.5.0
golang.org/x/tools v0.3.0
google.golang.org/grpc v1.53.0
golang.org/x/net v0.31.0
golang.org/x/tools v0.22.0
google.golang.org/grpc v1.65.0
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/coreos/go-systemd/v22 v22.4.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/kr/text v0.1.0 // indirect
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/sercand/kuberesolver/v5 v5.1.1 // indirect
go.uber.org/atomic v1.5.1 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading