diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da6b59f56..99494c751 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,19 +20,26 @@ permissions: env: NFPM_VERSION: 'v2.35.3' - GOPROXY: "https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@azr.artifactory.f5net.com/artifactory/api/go/f5-nginx-go-dev" + GOPROXY: "direct" jobs: - set-vars: + proxy-sanity-check: + name: Proxy Sanity Check runs-on: ubuntu-22.04 + if: ${{ !github.event.pull_request.head.repo.fork }} + env: + GOPROXY: "https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@azr.artifactory.f5net.com/artifactory/api/go/f5-nginx-go-dev" steps: - - name: Set Variables + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-tags: 'true' + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version-file: 'go.mod' + cache: false + - name: run goproxy-sanity-check run: | - if [[ -z ${{ secrets.ARTIFACTORY_USER }} ]] || - [[ -z ${{ secrets.ARTIFACTORY_TOKEN }} ]] || - ${{ github.event.pull_request.head.repo.fork }}; then - echo "GOPROXY=direct" >> $GITHUB_ENV - fi + make build lint: name: Lint @@ -47,6 +54,7 @@ jobs: run: make install-tools - name: run lint run: make lint + unit-test: name: Unit Tests runs-on: ubuntu-22.04 @@ -63,9 +71,10 @@ jobs: with: config: ./.testcoverage.yaml ## when token is not specified (value '') this feature is turned off - git-token: ${{ github.ref_name == 'v3' && secrets.GITHUB_TOKEN || '' }} + git-token: ${{ github.ref_name == 'main' && secrets.GITHUB_TOKEN || '' }} ## name of orphaned branch where badges are stored git-branch: badges + race-condition-test: name: Unit tests with race condition detection runs-on: ubuntu-22.04 @@ -77,11 +86,14 @@ jobs: cache: false - name: Run unit tests with race condition detection run: make race-condition-test + build-unsigned-snapshot: name: Build Unsigned Snapshot runs-on: ubuntu-22.04 steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-tags: 'true' - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version-file: 'go.mod' @@ -247,7 +259,7 @@ jobs: gh-pages-branch: "benchmark-results" fail-on-alert: true - name: Push benchmark result - if: ${{ success() && github.ref_name == 'v3'}} + if: ${{ success() && github.ref_name == 'main'}} run: git push 'https://github-actions:${{ secrets.GITHUB_TOKEN }}@github.com/nginx/agent.git' benchmark-results:benchmark-results load-tests: name: Load Tests @@ -314,10 +326,10 @@ jobs: benchmark-data-dir-path: "" # Set auto-push to false since GitHub API token is not given auto-push: false - alert-threshold: '175%' + alert-threshold: '125%' gh-pages-branch: "benchmark-results" fail-on-alert: true - name: Push load test result - if: ${{ success() && github.ref_name == 'v3'}} + if: ${{ success() && github.ref_name == 'main' }} run: git push 'https://github-actions:${{ secrets.GITHUB_TOKEN }}@github.com/nginx/agent.git' benchmark-results:benchmark-results diff --git a/Makefile b/Makefile index 9df9dcca7..19467116d 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,10 @@ MANIFEST_DIR ?= /var/lib/nginx-agent DIRS = $(BUILD_DIR) $(TEST_BUILD_DIR) $(BUILD_DIR)/$(DOCS_DIR) $(BUILD_DIR)/$(DOCS_DIR)/$(PROTO_DIR) $(shell mkdir -p $(DIRS)) -VERSION ?= "v3.0.0" +VERSION ?= $(shell git describe --match "v[0-9]*" --abbrev=0 --tags) +ifeq ($(strip $(VERSION)),) + VERSION := $(shell curl https://api.github.com/repos/nginx/agent/releases/latest -s | jq .name -r) +endif COMMIT = $(shell git rev-parse --short HEAD) DATE = $(shell date +%F_%H-%M-%S) LDFLAGS = "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)" @@ -104,7 +107,6 @@ include Makefile.containers include Makefile.packaging .PHONY: help clean no-local-changes build lint format unit-test integration-test run dev run-mock-management-grpc-server generate generate-mocks local-apk-package local-deb-package local-rpm-package - help: ## Show help message @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\033[36m\033[0m\n"} /^[$$()% 0-9a-zA-Z_-]+:.*?##/ { printf " \033[36m%-24s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)