Skip to content

Commit

Permalink
Build debs in test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
DazWorrall committed Feb 9, 2024
1 parent 82e0615 commit 54b58c4
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 15 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@ sudo apt-get update
sudo apt-get install -y make

# We set this here, so it's the same between the copydb and sharding debian
# package.
DATETIME=$(date -u +%Y%m%d%H%M%S)
# package, and between different arch builds
DATETIME=$(date -u +%Y%m%d)

git status

make copydb-deb DATETIME=${DATETIME}
make sharding-deb DATETIME=${DATETIME}

cd build
sha256sum *.deb > ghostferry-$GITHUB_SHA.sha256sum

set +x

echo "Debian package built successfully as follows:"
ls -l ghostferry*

echo "sha256sum:"
cat ghostferry-$GITHUB_SHA.sha256sum

# Make sure the we didn't release a dirty build by accident
if ls | grep -q dirty; then
echo "ERROR: source directory is not clean! refused to release. showing git status below:"
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,44 @@ jobs:

- name: Running Ruby tests
run: bundle exec ruby test/main.rb
build-debs:
strategy:
matrix:
runner: [ubuntu-latest, shopify-ubuntu-arm64]
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Building Ghostferry
run: .github/workflows/build-deb.sh

- name: Upload debs
uses: actions/upload-artifact@v3
with:
name: debs
path: build/ghostferry*

checksum-debs:
runs-on: ubuntu-latest
needs: build-debs
steps:
- name: Fetch uploaded artifacts
uses: actions/download-artifact@v3
with:
name: debs
- name: shasum
shell: bash
run: |
sha256sum *.deb > ghostferry-$GITHUB_SHA.sha256sum
echo "sha256sum:"
cat ghostferry-$GITHUB_SHA.sha256sum
- name: Upload checksum
uses: actions/upload-artifact@v3
with:
name: debs
path: "*.sha256sum"
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ BIN_DIR := usr/bin
PROJECTS := copydb sharding
PROJECT_DEBS := $(foreach name,$(PROJECTS),$(name)-deb)

PLATFORM := $(shell uname -s | tr A-Z a-z)
ARCH := $(shell uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g')
GOTESTSUM_URL := "https://github.com/gotestyourself/gotestsum/releases/download/v1.7.0/gotestsum_1.7.0_$(PLATFORM)_$(ARCH).tar.gz"

# Target specific variable, set proj to have a valid value.
PROJECT_PKG = ./$(proj)/cmd
PROJECT_BIN = ghostferry-$(proj)
BIN_TARGET = $(GOBIN)/$(PROJECT_BIN)
DEB_TARGET = $(BUILD_DIR)/$(PROJECT_BIN)_$(VERSION_STR).deb

PLATFORM := $(shell uname -s | tr A-Z a-z)
ARCH := $(shell uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g')
GOTESTSUM_URL := "https://github.com/gotestyourself/gotestsum/releases/download/v1.7.0/gotestsum_1.7.0_$(PLATFORM)_$(ARCH).tar.gz"
DEB_TARGET = $(BUILD_DIR)/$(PROJECT_BIN)_$(VERSION_STR)_$(ARCH).deb

.PHONY: test test-go test-ruby clean reset-deb-dir $(PROJECTS) $(PROJECT_DEBS)
.DEFAULT_GOAL := test
Expand All @@ -46,7 +46,7 @@ $(PROJECTS): $(GOBIN)
$(PROJECT_DEBS): LDFLAGS += -X github.com/Shopify/ghostferry.WebUiBasedir=/$(SHARE_DIR)
$(PROJECT_DEBS): reset-deb-dir
$(eval proj := $(subst -deb,,$@))
sed -e "s/{version}/$(VERSION_STR)/" $(proj)/debian/control > $(DEB_PREFIX)/DEBIAN/control
sed -e "s/{version}/$(VERSION_STR)/" -e "s/{arch}/$(ARCH)/" $(proj)/debian/control > $(DEB_PREFIX)/DEBIAN/control
cp $(proj)/debian/copyright $(DEB_PREFIX)/DEBIAN/copyright
go build -ldflags "$(LDFLAGS)" -o $(DEB_PREFIX)/$(BIN_DIR)/$(PROJECT_BIN) $(PROJECT_PKG)
cp -ar webui $(DEB_PREFIX)/$(SHARE_DIR)
Expand Down
2 changes: 1 addition & 1 deletion copydb/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: ghostferry-copydb
Version: {version}-1
Section: misc
Priority: optional
Architecture: amd64
Architecture: {arch}
Maintainer: Shuhao Wu <[email protected]>
Description: Migrate MySQL data from one server to another
without downtime via ghostferry.
2 changes: 1 addition & 1 deletion sharding/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: ghostferry-sharding
Version: {version}
Section: misc
Priority: optional
Architecture: amd64
Architecture: {arch}
Maintainer: Shuhao Wu <[email protected]>
Uploaders: Justin Li <[email protected]>,Hormoz Kheradmand <[email protected]>
Description: Migrate MySQL sharded data from one server to
Expand Down

0 comments on commit 54b58c4

Please sign in to comment.