From 1741c82839119f88c3b418e250475ff30dd37995 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Tue, 25 Jan 2022 18:10:13 -0700 Subject: [PATCH] Produce build for every pull request --- .github/workflows/abs_integration_test.yml | 25 ---- .github/workflows/gcp_integration_test.yml | 30 ----- .github/workflows/integration_test.yml | 127 ++++++++++++++++++ .github/workflows/long_running_test.yml | 23 ---- .github/workflows/release.linux.yml | 84 +++++++++--- .github/workflows/release.linux_static.yml | 62 --------- .github/workflows/s3_integration_test.yml | 28 ---- .../workflows/sftp_integration_test.yml.bak | 34 ----- 8 files changed, 191 insertions(+), 222 deletions(-) delete mode 100644 .github/workflows/abs_integration_test.yml delete mode 100644 .github/workflows/gcp_integration_test.yml create mode 100644 .github/workflows/integration_test.yml delete mode 100644 .github/workflows/long_running_test.yml delete mode 100644 .github/workflows/release.linux_static.yml delete mode 100644 .github/workflows/s3_integration_test.yml delete mode 100644 .github/workflows/sftp_integration_test.yml.bak diff --git a/.github/workflows/abs_integration_test.yml b/.github/workflows/abs_integration_test.yml deleted file mode 100644 index 991ecec..0000000 --- a/.github/workflows/abs_integration_test.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Azure Blob Store Integration Tests -on: pull_request - -jobs: - abs-integration-test: - name: Run Integration Tests - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-go@v2 - with: - go-version: '1.17' - - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ inputs.os }}-go- - - - run: go test -v -run=TestReplicaClient ./integration -replica-type abs - env: - LITESTREAM_ABS_ACCOUNT_NAME: ${{ secrets.LITESTREAM_ABS_ACCOUNT_NAME }} - LITESTREAM_ABS_ACCOUNT_KEY: ${{ secrets.LITESTREAM_ABS_ACCOUNT_KEY }} - LITESTREAM_ABS_BUCKET: integration diff --git a/.github/workflows/gcp_integration_test.yml b/.github/workflows/gcp_integration_test.yml deleted file mode 100644 index 1cab2f8..0000000 --- a/.github/workflows/gcp_integration_test.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: GCP Integration Tests -on: pull_request - -jobs: - gcp-integration-test: - name: Run GCP Integration Tests - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-go@v2 - with: - go-version: '1.17' - - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ inputs.os }}-go- - - - name: Extract GCP credentials - run: 'echo "$GOOGLE_APPLICATION_CREDENTIALS" > /opt/gcp.json' - shell: bash - env: - GOOGLE_APPLICATION_CREDENTIALS: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}} - - - run: go test -v -run=TestReplicaClient ./integration -replica-type gcs - env: - GOOGLE_APPLICATION_CREDENTIALS: /opt/gcp.json - LITESTREAM_GCS_BUCKET: integration.litestream.io diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml new file mode 100644 index 0000000..1ac40fb --- /dev/null +++ b/.github/workflows/integration_test.yml @@ -0,0 +1,127 @@ +name: Integration Tests +on: pull_request + +jobs: + s3-integration-test: + name: Run S3 Integration Tests + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-go@v2 + with: + go-version: '1.17' + + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ inputs.os }}-go- + + - run: go install ./cmd/litestream + + - run: go test -v -run=TestReplicaClient ./integration -replica-type s3 + env: + LITESTREAM_S3_ACCESS_KEY_ID: ${{ secrets.LITESTREAM_S3_ACCESS_KEY_ID }} + LITESTREAM_S3_SECRET_ACCESS_KEY: ${{ secrets.LITESTREAM_S3_SECRET_ACCESS_KEY }} + LITESTREAM_S3_REGION: us-east-1 + LITESTREAM_S3_BUCKET: integration.litestream.io + + gcp-integration-test: + name: Run GCP Integration Tests + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-go@v2 + with: + go-version: '1.17' + + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ inputs.os }}-go- + + - name: Extract GCP credentials + run: 'echo "$GOOGLE_APPLICATION_CREDENTIALS" > /opt/gcp.json' + shell: bash + env: + GOOGLE_APPLICATION_CREDENTIALS: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}} + + - run: go test -v -run=TestReplicaClient ./integration -replica-type gcs + env: + GOOGLE_APPLICATION_CREDENTIALS: /opt/gcp.json + LITESTREAM_GCS_BUCKET: integration.litestream.io + + abs-integration-test: + name: Run Azure Blob Store Integration Tests + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-go@v2 + with: + go-version: '1.17' + + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ inputs.os }}-go- + + - run: go test -v -run=TestReplicaClient ./integration -replica-type abs + env: + LITESTREAM_ABS_ACCOUNT_NAME: ${{ secrets.LITESTREAM_ABS_ACCOUNT_NAME }} + LITESTREAM_ABS_ACCOUNT_KEY: ${{ secrets.LITESTREAM_ABS_ACCOUNT_KEY }} + LITESTREAM_ABS_BUCKET: integration + +# sftp-integration-test: +# name: Run SFTP Integration Tests +# runs-on: ubuntu-18.04 +# steps: +# - uses: actions/checkout@v2 +# +# - uses: actions/setup-go@v2 +# with: +# go-version: '1.17' +# +# - uses: actions/cache@v2 +# with: +# path: ~/go/pkg/mod +# key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }} +# restore-keys: ${{ inputs.os }}-go- +# +# - name: Extract SSH key +# run: 'echo "$LITESTREAM_SFTP_KEY" > /opt/id_ed25519' +# shell: bash +# env: +# LITESTREAM_SFTP_KEY: ${{secrets.LITESTREAM_SFTP_KEY}} +# +# - name: Run sftp tests +# run: go test -v -run=TestReplicaClient ./integration -replica-type sftp +# env: +# LITESTREAM_SFTP_HOST: ${{ secrets.LITESTREAM_SFTP_HOST }} +# LITESTREAM_SFTP_USER: ${{ secrets.LITESTREAM_SFTP_USER }} +# LITESTREAM_SFTP_KEY_PATH: /opt/id_ed25519 +# LITESTREAM_SFTP_PATH: ${{ secrets.LITESTREAM_SFTP_PATH }} + + long-running-test: + name: Run Long-Running Test + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-go@v2 + with: + go-version: '1.17' + + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ inputs.os }}-go- + + - run: go install ./cmd/litestream + + - run: go test -v -run=TestCmd_Replicate_LongRunning ./integration -long-running-duration 1m diff --git a/.github/workflows/long_running_test.yml b/.github/workflows/long_running_test.yml deleted file mode 100644 index 3827b1a..0000000 --- a/.github/workflows/long_running_test.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Long-Running Unit Test -on: pull_request - -jobs: - test: - name: Run Long Running Unit Test - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-go@v2 - with: - go-version: '1.17' - - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ inputs.os }}-go- - - - run: go install ./cmd/litestream - - - run: go test -v -run=TestCmd_Replicate_LongRunning ./integration -long-running-duration 1m diff --git a/.github/workflows/release.linux.yml b/.github/workflows/release.linux.yml index ce80a95..8950913 100644 --- a/.github/workflows/release.linux.yml +++ b/.github/workflows/release.linux.yml @@ -2,41 +2,68 @@ on: release: types: - created + pull_request: + types: + - opened + - synchronize + - reopened -name: release (linux) +name: Release (Linux) jobs: build: runs-on: ubuntu-18.04 strategy: matrix: include: - - arch: amd64 - cc: gcc + - arch: amd64 + cc: gcc + + - arch: amd64 + cc: gcc + static: true + - arch: arm64 cc: aarch64-linux-gnu-gcc + + - arch: arm64 + cc: aarch64-linux-gnu-gcc + static: true + - arch: arm arm: 6 cc: arm-linux-gnueabi-gcc + + - arch: arm + arm: 6 + cc: arm-linux-gnueabi-gcc + static: true + - arch: arm arm: 7 cc: arm-linux-gnueabihf-gcc + - arch: arm + arm: 7 + cc: arm-linux-gnueabihf-gcc + static: true + env: GOOS: linux GOARCH: ${{ matrix.arch }} GOARM: ${{ matrix.arm }} CC: ${{ matrix.cc }} + LDFLAGS: ${{ matrix.static && '-extldflags "-static"' || '' }} + TAGS: ${{ matrix.static && 'osusergo,netgo,sqlite_omit_load_extension' || '' }} + SUFFIX: "${{ matrix.static && '-static' || ''}}" + VERSION: "${{ github.event_name == 'release' && github.event.release.name || github.sha }}" + steps: - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 with: - go-version: '1.16' - - - id: release - uses: bruceadams/get-release@v1.2.2 - env: - GITHUB_TOKEN: ${{ github.token }} + go-version: '1.17' - name: Install cross-compilers run: | @@ -50,32 +77,49 @@ jobs: - name: Build litestream run: | - rm -rf dist - mkdir -p dist + rm -rf dist && mkdir -p dist + cp etc/litestream.yml etc/litestream.service dist - cat etc/nfpm.yml | LITESTREAM_VERSION=${{ steps.release.outputs.tag_name }} envsubst > dist/nfpm.yml - CGO_ENABLED=1 go build -ldflags "-s -w -X 'main.Version=${{ steps.release.outputs.tag_name }}'" -o dist/litestream ./cmd/litestream - + cat etc/nfpm.yml | LITESTREAM_VERSION=${{ env.VERSION }} envsubst > dist/nfpm.yml + + CGO_ENABLED=1 go build -ldflags "-s -w ${{ env.LDFLAGS }} -X 'main.Version=${{ env.VERSION }}'" -tags "${{ env.TAGS }}" -o dist/litestream ./cmd/litestream + cd dist - tar -czvf litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}.tar.gz litestream - ../nfpm pkg --config nfpm.yml --packager deb --target litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}.deb + tar -czvf litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.tar.gz litestream + ../nfpm pkg --config nfpm.yml --packager deb --target litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.deb + + - name: Upload binary artifact + uses: actions/upload-artifact@v2 + with: + name: litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.tar.gz + path: dist/litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.tar.gz + if-no-files-found: error + + - name: Upload debian artifact + uses: actions/upload-artifact@v2 + with: + name: litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.deb + path: dist/litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.deb + if-no-files-found: error - name: Upload release tarball uses: actions/upload-release-asset@v1.0.2 + if: github.event_name == 'release' env: GITHUB_TOKEN: ${{ github.token }} with: upload_url: ${{ steps.release.outputs.upload_url }} - asset_path: ./dist/litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}.tar.gz - asset_name: litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}.tar.gz + asset_path: ./dist/litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.tar.gz + asset_name: litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.tar.gz asset_content_type: application/gzip - name: Upload debian package uses: actions/upload-release-asset@v1.0.2 + if: github.event_name == 'release' env: GITHUB_TOKEN: ${{ github.token }} with: upload_url: ${{ steps.release.outputs.upload_url }} - asset_path: ./dist/litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}.deb - asset_name: litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}.deb + asset_path: ./dist/litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.deb + asset_name: litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.deb asset_content_type: application/octet-stream diff --git a/.github/workflows/release.linux_static.yml b/.github/workflows/release.linux_static.yml deleted file mode 100644 index ddc90b9..0000000 --- a/.github/workflows/release.linux_static.yml +++ /dev/null @@ -1,62 +0,0 @@ -on: - release: - types: - - created - -name: release (linux/static) -jobs: - build: - runs-on: ubuntu-18.04 - strategy: - matrix: - include: - - arch: amd64 - cc: gcc - - arch: arm64 - cc: aarch64-linux-gnu-gcc - - arch: arm - arm: 6 - cc: arm-linux-gnueabi-gcc - - arch: arm - arm: 7 - cc: arm-linux-gnueabihf-gcc - - env: - GOOS: linux - GOARCH: ${{ matrix.arch }} - GOARM: ${{ matrix.arm }} - CC: ${{ matrix.cc }} - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: '1.16' - - - id: release - uses: bruceadams/get-release@v1.2.2 - env: - GITHUB_TOKEN: ${{ github.token }} - - - name: Install cross-compilers - run: | - sudo apt-get update - sudo apt-get install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-arm-linux-gnueabi - - - name: Build litestream - run: | - rm -rf dist - mkdir -p dist - CGO_ENABLED=1 go build -ldflags "-s -w -extldflags "-static" -X 'main.Version=${{ steps.release.outputs.tag_name }}'" -tags osusergo,netgo,sqlite_omit_load_extension -o dist/litestream ./cmd/litestream - cd dist - tar -czvf litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}-static.tar.gz litestream - - - name: Upload release tarball - uses: actions/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - upload_url: ${{ steps.release.outputs.upload_url }} - asset_path: ./dist/litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}-static.tar.gz - asset_name: litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}-static.tar.gz - asset_content_type: application/gzip diff --git a/.github/workflows/s3_integration_test.yml b/.github/workflows/s3_integration_test.yml deleted file mode 100644 index 6fac1b3..0000000 --- a/.github/workflows/s3_integration_test.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: S3 Integration Tests -on: pull_request - -jobs: - test: - name: Run S3 Integration Tests - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-go@v2 - with: - go-version: '1.17' - - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ inputs.os }}-go- - - - run: go install ./cmd/litestream - - - run: go test -v -run=TestReplicaClient ./integration -replica-type s3 - env: - LITESTREAM_S3_ACCESS_KEY_ID: ${{ secrets.LITESTREAM_S3_ACCESS_KEY_ID }} - LITESTREAM_S3_SECRET_ACCESS_KEY: ${{ secrets.LITESTREAM_S3_SECRET_ACCESS_KEY }} - LITESTREAM_S3_REGION: us-east-1 - LITESTREAM_S3_BUCKET: integration.litestream.io diff --git a/.github/workflows/sftp_integration_test.yml.bak b/.github/workflows/sftp_integration_test.yml.bak deleted file mode 100644 index 3c8bc89..0000000 --- a/.github/workflows/sftp_integration_test.yml.bak +++ /dev/null @@ -1,34 +0,0 @@ -#name: SFTP Integration Tests -#on: pull_request -# -#jobs: -# sftp-integration-test: -# name: Run SFTP Integration Tests -# runs-on: ubuntu-18.04 -# steps: -# - uses: actions/checkout@v2 -# -# - uses: actions/setup-go@v2 -# with: -# go-version: '1.17' -# -# - uses: actions/cache@v2 -# with: -# path: ~/go/pkg/mod -# key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }} -# restore-keys: ${{ inputs.os }}-go- -# -# - name: Extract SSH key -# run: 'echo "$LITESTREAM_SFTP_KEY" > /opt/id_ed25519' -# shell: bash -# env: -# LITESTREAM_SFTP_KEY: ${{secrets.LITESTREAM_SFTP_KEY}} -# -# - name: Run sftp tests -# run: go test -v -run=TestReplicaClient ./integration -replica-type sftp -# env: -# LITESTREAM_SFTP_HOST: ${{ secrets.LITESTREAM_SFTP_HOST }} -# LITESTREAM_SFTP_USER: ${{ secrets.LITESTREAM_SFTP_USER }} -# LITESTREAM_SFTP_KEY_PATH: /opt/id_ed25519 -# LITESTREAM_SFTP_PATH: ${{ secrets.LITESTREAM_SFTP_PATH }} -