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

Convert gocardless/stolon-pgbouncer to Github Actions #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
88 changes: 88 additions & 0 deletions .github/workflows/build-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: gocardless/stolon-pgbouncer/build-integration
on:
push:
env:
DOCKER_PASS: xxxx9e14
DOCKER_USER: xxxxdmin
GITHUB_TOKEN: xxxx6d08
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this was set to before. We might be able to get away with the usual GITHUB_TOKEN injected by GHA.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Sam 👋

A note of warning: this is a public repo that anyone can open PRs to, so you’ll want to double check you don’t respond to those changes by running builds on any private GitHub agents you may have had around.

Especially if you’re relying on ambient creds on those machines, which might mean people outside of GC could exfiltrate GitHub resources under the GC org by misusing the creds.

I’ve not checked this super closely, but wanted to warn you in case you hadn’t considered it. It may make more sense to leave this and other open source repos on Circle, to avoid exposing the private infra.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Lawrence,

Thanks for the heads up!
We don't have self-hosted runners set up just yet, but when we do we'll restrict them to run solely on private repositories, and leave public repos to use Github's runners.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, wanted to nudge you in case it had gone under the radar, but sounds like you’re on it :)

jobs:
unit-integration:
defaults:
run:
working-directory: "/go/src/github.com/gocardless/stolon-pgbouncer"
runs-on: ubuntu-latest
container:
image: gocardless/stolon-pgbouncer-circleci:2020050701
env:
PGHOST: 127.0.0.1
PGUSER: postgres
steps:
- uses: actions/checkout@v2
- name: Compile ginkgo test suites
run: ginkgo build -r -race .
- name: Run unit tests
run: find pkg -type f -name '*.test' -printf "%h %f\n" | xargs -n2 sh -c 'cd $0 && su postgres -c ./$1'
build:
defaults:
run:
working-directory: "/go/src/github.com/gocardless/stolon-pgbouncer"
runs-on: ubuntu-latest
container:
image: gocardless/stolon-pgbouncer-circleci:2020050701
steps:
- uses: actions/checkout@v2
- name: Build test binaries
run: make linux
- uses: actions/upload-artifact@v2
with:
path: |-
/go/src/github.com/gocardless/stolon-pgbouncer/bin/stolon-pgbouncer.linux_amd64
/go/src/github.com/gocardless/stolon-pgbouncer/bin/stolon-pgbouncer-acceptance.linux_amd64
Comment on lines +36 to +40
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think uploading and downloading the artifact here and below is unnecessary. We could probably just bundle the build & acceptance into one job?

acceptance:
defaults:
run:
working-directory: "/home/circleci/stolon-pgbouncer"
runs-on: ubuntu-20.04
needs:
- build
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
path: "/home/circleci/stolon-pgbouncer"
- name: Install an up-to-date Docker Compose
run: |-
curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
chmod +x ~/docker-compose
sudo mv ~/docker-compose /usr/local/bin/docker-compose
- name: Start docker-compose cluster
run: docker-compose up -d etcd-store sentinel pgbouncer keeper0 keeper1 keeper2
- name: Tail logs from docker-compose
run: docker-compose logs -f
- name: Run acceptance tests
run: bin/stolon-pgbouncer-acceptance.linux_amd64
release:
if: contains('refs/heads/master', github.ref)
defaults:
run:
working-directory: "/go/src/github.com/gocardless/stolon-pgbouncer"
runs-on: ubuntu-latest
container:
image: gocardless/stolon-pgbouncer-circleci:2020050701
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
image: gocardless/stolon-pgbouncer-circleci:2020050701
image: gocardless/stolon-pgbouncer-ci:2020050701

We should remove references to circle throughout the repo.

needs:
- acceptance
- unit-integration
steps:
# # 'setup_remote_docker' was not transformed because there is no suitable equivalent in GitHub Actions
- run: docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like our image installs docker so we can get away without adding much here. What registry are we wanting to login to? If it is GCR then we might want to make use of workload identity federation so we can bin some long lived credentials https://github.com/docker/login-action#google-container-registry-gcr

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using docker hub, as this is a public project.

https://hub.docker.com/r/gocardless/stolon-pgbouncer/tags

- uses: actions/checkout@v2
- name: Release
run: |-
CURRENT_VERSION="v$(cat VERSION)"
if [[ $(git tag -l "${CURRENT_VERSION}") == "${CURRENT_VERSION}" ]]; then
echo "Version ${CURRENT_VERSION} is already released"
exit 0
fi
git tag "${CURRENT_VERSION}"
git push --tags
goreleaser --rm-dist