diff --git a/.github/workflows/build-deb.sh b/.github/workflows/build-deb.sh new file mode 100755 index 00000000..6baa68e1 --- /dev/null +++ b/.github/workflows/build-deb.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -xe + +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) + +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:" + git status + exit 1 +fi diff --git a/.travisci/build-docs.sh b/.github/workflows/build-docs.sh similarity index 71% rename from .travisci/build-docs.sh rename to .github/workflows/build-docs.sh index 37280ddb..3bc21748 100755 --- a/.travisci/build-docs.sh +++ b/.github/workflows/build-docs.sh @@ -9,8 +9,9 @@ cd docs make html cd build -git clone --depth 1 https://github.com/$TRAVIS_REPO_SLUG -b gh-pages ghostferry-pages -cp -ar html/. ghostferry-pages/$TRAVIS_BRANCH +git clone --depth 1 https://github.com/Shopify/ghostferry.git -b gh-pages ghostferry-pages +current_branch=${GITHUB_REF#refs/heads/} +cp -ar html/. ghostferry-pages/${current_branch} cd ghostferry-pages echo "" > index.html @@ -27,4 +28,8 @@ echo " " >> index.html echo " " >> index.html echo "" >> index.html -rm -rf .git +git status + +cd ../../.. +ls -la docs/build/ghostferry-pages +rm .git -rf diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 00000000..137004c2 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,23 @@ +name: Documentation on github pages + +on: + push: + branches: + - master + +jobs: + github-pages: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Build documentations + run: .github/workflows/build-docs.sh + + + - name: Deploy github pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/build/ghostferry-pages + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..71170dd5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,25 @@ +name: Package and release on Github + +on: + push: + branches: + - master + +jobs: + release: + runs-on: ubuntu-latest + 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: Releasing Ghostferry to Github + run: gh release create --target ${GITHUB_REF#refs/heads/} -p release-${GITHUB_SHA::8} build/ghostferry* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 38758e99..00000000 --- a/.travis.yml +++ /dev/null @@ -1,67 +0,0 @@ -if: (type = push AND (branch = master OR branch = experimental)) OR type = pull_request - -os: - - linux -dist: xenial - -language: go - -go: "1.14.1" -go_import_path: github.com/Shopify/ghostferry - -services: - - docker - -stages: - - Test - - name: Documentation - if: type = push AND branch = master - - name: Package - if: type = push AND (branch = master OR branch = experimental) - -env: - global: - - CI=true - - DOCKER_COMPOSE_VERSION=1.21.2 - -jobs: - include: - - stage: Test - name: Go Tests - script: make test-go - - script: make test-ruby - name: Ruby Tests - - stage: Documentation - script: .travisci/build-docs.sh - deploy: - - provider: pages - strategy: git - token: "$GITHUB_TOKEN" - keep_history: true - local_dir: docs/build/ghostferry-pages - skip_cleanup: true - - stage: Package - script: - - .travisci/build-docs.sh - - .travisci/build-debs.sh - - .travisci/deploy-packagecloud.sh - deploy: - - provider: releases - token: "$GITHUB_TOKEN" - file_glob: true - file: build/ghostferry-*.deb - skip_cleanup: true - on: - tags: true - -before_script: - - ulimit -n 16384 - -install: - # Installing Docker Compose - - sudo rm /usr/local/bin/docker-compose - - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose - - chmod +x docker-compose - - sudo mv docker-compose /usr/local/bin - # Installing and Starting MySQL - - .travisci/start-mysql.sh diff --git a/.travisci/build-debs.sh b/.travisci/build-debs.sh deleted file mode 100755 index a1c57605..00000000 --- a/.travisci/build-debs.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -set -xe - -make copydb-deb IGNORE_DIRTY_TREE=1 -make sharding-deb IGNORE_DIRTY_TREE=1 diff --git a/.travisci/deploy-packagecloud.sh b/.travisci/deploy-packagecloud.sh deleted file mode 100755 index f76cd469..00000000 --- a/.travisci/deploy-packagecloud.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -xe - -gem install package_cloud - -packagecloud_url="https://packages.shopify.io" -repo="shopify/ghostferry" - -for dist in {ubuntu/trusty,ubuntu/xenial,ubuntu/bionic,ubuntu/cosmic}; do - package_cloud push --url "$packagecloud_url" "$repo/$dist" build/ghostferry-*.deb -done diff --git a/.travisci/start-mysql.sh b/.travisci/start-mysql.sh deleted file mode 100755 index 1600c667..00000000 --- a/.travisci/start-mysql.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -set -e - -echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin -docker-compose up -d mysql-1 mysql-2 - -# We need a way to check if the mysql servers have booted or not before running -# the tests and this way is slightly faster than installing mysql-client - -wait_for_mysql() { - port=$1 - echo "Waiting for MySQL at port $port..." - attempts=0 - while ! nc -w 1 localhost $port | grep -q "mysql"; do - sleep 1 - attempts=$((attempts + 1)) - if (( attempts > 60 )); then - echo "ERROR: mysql $port was not started." >&2 - exit 1 - fi - done - echo "MySQL at port $port has started!" -} - -wait_for_mysql 29291 -wait_for_mysql 29292 diff --git a/Makefile b/Makefile index f3a8a4b0..7cf52d98 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Variables to be built into the binary VERSION := 1.1.0 -DATETIME := $(shell date -u +%Y%m%d%H%M%S) +DATETIME ?= $(shell date -u +%Y%m%d%H%M%S) # This variable can be overwritten by the caller ifndef IGNORE_DIRTY_TREE DIRTY_TREE := $(shell git diff-index --quiet HEAD -- || echo '+dirty')