From a0ec481ddfeca2728073da3e6f72f2772f1a7908 Mon Sep 17 00:00:00 2001 From: dhurley Date: Tue, 25 Jun 2024 14:25:42 +0100 Subject: [PATCH 1/4] Fix release workflow --- .github/workflows/release-branch.yml | 3 ++- Makefile.packaging | 2 -- sdk/config_helpers.go | 4 ++-- sdk/config_helpers_test.go | 14 +++++++------- .../nginx/agent/sdk/v2/config_helpers.go | 4 ++-- .../nginx/agent/sdk/v2/config_helpers.go | 4 ++-- .../nginx/agent/sdk/v2/config_helpers.go | 4 ++-- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release-branch.yml b/.github/workflows/release-branch.yml index e3b1d3190..2a2d2420f 100644 --- a/.github/workflows/release-branch.yml +++ b/.github/workflows/release-branch.yml @@ -182,8 +182,9 @@ jobs: if: ${{ inputs.publishPackages == true }} env: TOKEN: ${{ inputs.uploadJWT }} + UPLOAD_URL: ${{ secrets.UPLOAD_URL }} run: | - UPLOAD_URL=${{ secrets.UPLOAD_URL}} make release + make release - name: Publish Github Release if: ${{ inputs.publishPackages == true }} uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 diff --git a/Makefile.packaging b/Makefile.packaging index e6954b2b7..c39918b95 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -24,8 +24,6 @@ ALMA_ARCHS?=aarch64 x86_64 AMAZON_VERSIONS?=amazon-2 amazon-2023 AMAZON_ARCHS?=aarch64 x86_64 -UPLOAD_URL ?= "https://up-ap.nginx.com/" - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Release Packaging # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # diff --git a/sdk/config_helpers.go b/sdk/config_helpers.go index b9ade1a44..0b6f32e8d 100644 --- a/sdk/config_helpers.go +++ b/sdk/config_helpers.go @@ -174,8 +174,8 @@ func updateNginxConfigFromPayload( // cache the directory map, so we can look up using the base directoryMap := newDirectoryMap() - formatMap := map[string]string{} // map of accessLog/errorLog formats - seen := make(map[string]struct{}) // local cache of seen files + formatMap := map[string]string{} // map of accessLog/errorLog formats + seen := make(map[string]struct{}) // local cache of seen files seenCerts := make(map[string]*x509.Certificate) // local cache of seen certs // Add files to the zipped config in a consistent order. diff --git a/sdk/config_helpers_test.go b/sdk/config_helpers_test.go index 1e7eb44fd..9b4cb585a 100644 --- a/sdk/config_helpers_test.go +++ b/sdk/config_helpers_test.go @@ -512,8 +512,8 @@ var tests = []struct { }, }, expectedAuxFiles: map[string]struct{}{ - "/tmp/testdata/foo/test.html": {}, - "/tmp/testdata/nginx/ca/ca.crt": {}, + "/tmp/testdata/foo/test.html": {}, + "/tmp/testdata/nginx/ca/ca.crt": {}, }, }, { @@ -795,8 +795,8 @@ var tests = []struct { }, }, expectedAuxFiles: map[string]struct{}{ - "/tmp/testdata/foo/test.html": {}, - "/tmp/testdata/nginx/ca/ca.crt": {}, + "/tmp/testdata/foo/test.html": {}, + "/tmp/testdata/nginx/ca/ca.crt": {}, }, }, } @@ -883,7 +883,7 @@ func TestGetNginxConfig(t *testing.T) { resultFile := resultDir.Files[fileIndex] assert.Equal(t, expectedFile.Name, resultFile.Name) assert.Equal(t, expectedFile.Permissions, resultFile.Permissions) - assert.Equal(t, expectedFile.Lines, resultFile.Lines, "unexpected line count for " + expectedDirectory.Name + "/" +expectedFile.Name) + assert.Equal(t, expectedFile.Lines, resultFile.Lines, "unexpected line count for "+expectedDirectory.Name+"/"+expectedFile.Name) } } @@ -1520,9 +1520,9 @@ func getCertMeta(file string) crtMetaFields { } func generateCertificates(algoname string) error { - certs := []string { "ca", "proxy", "trusted" } + certs := []string{"ca", "proxy", "trusted"} var cmd1 *exec.Cmd - + for _, cert := range certs { local := fmt.Sprintf("'%s.local'", cert) output := fmt.Sprintf("certs/conf/%s/", cert) diff --git a/test/integration/vendor/github.com/nginx/agent/sdk/v2/config_helpers.go b/test/integration/vendor/github.com/nginx/agent/sdk/v2/config_helpers.go index b9ade1a44..0b6f32e8d 100644 --- a/test/integration/vendor/github.com/nginx/agent/sdk/v2/config_helpers.go +++ b/test/integration/vendor/github.com/nginx/agent/sdk/v2/config_helpers.go @@ -174,8 +174,8 @@ func updateNginxConfigFromPayload( // cache the directory map, so we can look up using the base directoryMap := newDirectoryMap() - formatMap := map[string]string{} // map of accessLog/errorLog formats - seen := make(map[string]struct{}) // local cache of seen files + formatMap := map[string]string{} // map of accessLog/errorLog formats + seen := make(map[string]struct{}) // local cache of seen files seenCerts := make(map[string]*x509.Certificate) // local cache of seen certs // Add files to the zipped config in a consistent order. diff --git a/test/performance/vendor/github.com/nginx/agent/sdk/v2/config_helpers.go b/test/performance/vendor/github.com/nginx/agent/sdk/v2/config_helpers.go index b9ade1a44..0b6f32e8d 100644 --- a/test/performance/vendor/github.com/nginx/agent/sdk/v2/config_helpers.go +++ b/test/performance/vendor/github.com/nginx/agent/sdk/v2/config_helpers.go @@ -174,8 +174,8 @@ func updateNginxConfigFromPayload( // cache the directory map, so we can look up using the base directoryMap := newDirectoryMap() - formatMap := map[string]string{} // map of accessLog/errorLog formats - seen := make(map[string]struct{}) // local cache of seen files + formatMap := map[string]string{} // map of accessLog/errorLog formats + seen := make(map[string]struct{}) // local cache of seen files seenCerts := make(map[string]*x509.Certificate) // local cache of seen certs // Add files to the zipped config in a consistent order. diff --git a/vendor/github.com/nginx/agent/sdk/v2/config_helpers.go b/vendor/github.com/nginx/agent/sdk/v2/config_helpers.go index b9ade1a44..0b6f32e8d 100644 --- a/vendor/github.com/nginx/agent/sdk/v2/config_helpers.go +++ b/vendor/github.com/nginx/agent/sdk/v2/config_helpers.go @@ -174,8 +174,8 @@ func updateNginxConfigFromPayload( // cache the directory map, so we can look up using the base directoryMap := newDirectoryMap() - formatMap := map[string]string{} // map of accessLog/errorLog formats - seen := make(map[string]struct{}) // local cache of seen files + formatMap := map[string]string{} // map of accessLog/errorLog formats + seen := make(map[string]struct{}) // local cache of seen files seenCerts := make(map[string]*x509.Certificate) // local cache of seen certs // Add files to the zipped config in a consistent order. From 5400172d322c9dc6c96d8b3c282f43a463e527e2 Mon Sep 17 00:00:00 2001 From: dhurley Date: Tue, 25 Jun 2024 14:31:03 +0100 Subject: [PATCH 2/4] Test --- .github/workflows/ci.yml | 2 ++ Makefile.packaging | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 404cddc2d..0fb004cfc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,6 +58,8 @@ jobs: go-version-file: 'go.mod' - name: Run Unit Tests run: make unit-test + - name: Run Test + run: make release - name: Upload Test Coverage uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # v4.3.0 with: diff --git a/Makefile.packaging b/Makefile.packaging index c39918b95..2e259b6cc 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -190,5 +190,5 @@ gpg-key: ## Generate GPG public key release: ## Publish tarball to the UPLOAD_URL echo "Publishing nginx-agent packages to ${UPLOAD_URL}"; \ - curl -XPOST -F "file=@$(PACKAGES_DIR)/${PACKAGE_PREFIX}.tar.gz" -H "Token: ${TOKEN}" ${UPLOAD_URL}; \ - curl -XPOST -F "file=@$(GPG_PUBLIC_KEY)" -H "Token: ${TOKEN}" ${UPLOAD_URL}; \ + # curl -XPOST -F "file=@$(PACKAGES_DIR)/${PACKAGE_PREFIX}.tar.gz" -H "Token: ${TOKEN}" ${UPLOAD_URL}; \ + # curl -XPOST -F "file=@$(GPG_PUBLIC_KEY)" -H "Token: ${TOKEN}" ${UPLOAD_URL}; \ From f564c0b2593be389b81b2a6c7e056b74d58679f2 Mon Sep 17 00:00:00 2001 From: dhurley Date: Tue, 25 Jun 2024 14:39:08 +0100 Subject: [PATCH 3/4] Test --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fb004cfc..f3c54ccce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,10 +56,12 @@ jobs: - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version-file: 'go.mod' - - name: Run Unit Tests - run: make unit-test - name: Run Test + env: + UPLOAD_URL: ${{ secrets.UPLOAD_URL }} run: make release + - name: Run Unit Tests + run: make unit-test - name: Upload Test Coverage uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # v4.3.0 with: From 335c7129575611e8b11c35deec64e44cce61d27d Mon Sep 17 00:00:00 2001 From: dhurley Date: Tue, 25 Jun 2024 14:43:28 +0100 Subject: [PATCH 4/4] Test --- .github/workflows/ci.yml | 4 ---- Makefile.packaging | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3c54ccce..404cddc2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,10 +56,6 @@ jobs: - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version-file: 'go.mod' - - name: Run Test - env: - UPLOAD_URL: ${{ secrets.UPLOAD_URL }} - run: make release - name: Run Unit Tests run: make unit-test - name: Upload Test Coverage diff --git a/Makefile.packaging b/Makefile.packaging index 2e259b6cc..c39918b95 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -190,5 +190,5 @@ gpg-key: ## Generate GPG public key release: ## Publish tarball to the UPLOAD_URL echo "Publishing nginx-agent packages to ${UPLOAD_URL}"; \ - # curl -XPOST -F "file=@$(PACKAGES_DIR)/${PACKAGE_PREFIX}.tar.gz" -H "Token: ${TOKEN}" ${UPLOAD_URL}; \ - # curl -XPOST -F "file=@$(GPG_PUBLIC_KEY)" -H "Token: ${TOKEN}" ${UPLOAD_URL}; \ + curl -XPOST -F "file=@$(PACKAGES_DIR)/${PACKAGE_PREFIX}.tar.gz" -H "Token: ${TOKEN}" ${UPLOAD_URL}; \ + curl -XPOST -F "file=@$(GPG_PUBLIC_KEY)" -H "Token: ${TOKEN}" ${UPLOAD_URL}; \