From 4f04de74ffe599ea818d269c3f6e38db22d2ff07 Mon Sep 17 00:00:00 2001 From: Timur Zununbekov Date: Tue, 20 Feb 2024 16:02:52 +0600 Subject: [PATCH] Test env setup --- .github/workflows/build-packages.yml | 56 +++++++++++++++++-------- .github/workflows/tests-and-linters.yml | 4 +- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml index 957e694235..2170f62d22 100644 --- a/.github/workflows/build-packages.yml +++ b/.github/workflows/build-packages.yml @@ -3,7 +3,7 @@ name: Build packages on: workflow_call: push: - branches: [master, ci-migration] + branches: [master] tags: # Mage's `GenerateEnvFile` talks to GH API to setup tags, versions, etc. @@ -21,30 +21,46 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v5 with: - go-version: '1.21.x' + fetch-depth: 0 + fetch-tags: true - name: Prepare environment run: | - echo "BUILD_NUMBER=${{ github.repository }}-${{ github.workflow }}-${{ github.run_id }}-ghactions" >> $GITHUB_ENV - echo "BUILD_COMMIT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV - echo "BUILD_BRANCH_SAFE=${{ github.ref }}" >> $GITHUB_ENV - echo "BUILD_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - echo "BUILD_BRANCH=${{ github.ref }}" >> $GITHUB_ENV + RELEASE_BUILD=false + if [[ "${GITHUB_REF}" == /refs/tags/* ]]; then RELEASE_BUILD=true; fi - - name: Generate env file - run: go run mage.go -v GenerateEnvFile - - # - name: Create bucket - # if: github.event_name == 'push' - # run: go run mage.go -v MakeBucket + RC_BUILD=false + if [[ "${GITHUB_REF}" == /refs/tags/*-rc ]]; then RC_BUILD=true; fi + + SNAPSHOT_BUILD=false + if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then SNAPSHOT_BUILD=true; fi + + PR_BUILD=false + if [[ "${SNAPSHOT_BUILD}" == "false" && "${RELEASE_BUILD}" == "false" ]]; then PR_BUILD=true; fi + + BUILD_NUMBER="${{ github.run_id }}"-ghactions + + if [[ "${RELEASE_BUILD}" == "true" ]]; then + BUILD_VERSION="${GITHUB_REF#/refs/tags/}"; + elif [[ "${SNAPSHOT_BUILD}" == "true" ]]; then + BUILD_VERSION="$(git describe --abbrev=0 --tags)"-1snapshot-"$(date '+%Y%m%dT%H%M')"-"$(echo ${GITHUB_SHA} | cut -c1-8)"; + elif [[ "${PR_BUILD}" == "true" ]]; then + BUILD_VERSION="$(git describe --abbrev=0 --tags)"-1branch-"${GITHUB_HEAD_REF////-}"; + fi + + cat <> env.sh + export RELEASE_BUILD=$RELEASE_BUILD; + export RC_BUILD=$RC_BUILD; + export SNAPSHOT_BUILD=$SNAPSHOT_BUILD; + export BUILD_NUMBER=$BUILD_NUMBER; + export BUILD_VERSION=$BUILD_VERSION; + EOT - uses: actions/upload-artifact@v4 with: name: env.sh - path: build/env.sh + path: env.sh build-packages: runs-on: ubuntu-latest @@ -76,6 +92,12 @@ jobs: with: name: env.sh + - name: Create bucket + if: contains(github.ref, 'refs/tags') || github.ref == 'refs/heads/master' + run: | + source env.sh + go run mage.go -v MakeBucket + - name: Setup FPM run: | sudo apt-get install ruby-dev build-essential @@ -84,7 +106,7 @@ jobs: - name: Build package run: | source env.sh - go run mage.go -v ${{ matrix.platform }} + CI=false go run mage.go -v ${{ matrix.platform }} build-swagger: runs-on: ubuntu-latest diff --git a/.github/workflows/tests-and-linters.yml b/.github/workflows/tests-and-linters.yml index 1e1d6d26ba..30b1033992 100644 --- a/.github/workflows/tests-and-linters.yml +++ b/.github/workflows/tests-and-linters.yml @@ -1,6 +1,6 @@ name: Tests -# on: - # pull_request: +on: + pull_request: env: GOFLAGS: "-count=1"