diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 864e24d53..9ceed3942 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,23 +23,38 @@ env: GOPROXY: "direct" jobs: - proxy-sanity-check: - name: Proxy Sanity Check + cache-dependencies: + name: Cache Dependencies runs-on: ubuntu-22.04 - if: ${{ !github.event.pull_request.head.repo.fork && !startsWith(github.head_ref, 'dependabot-') }} - env: - GOPROXY: "https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@${{ secrets.ARTIFACTORY_URL_DEV }}" + if: github.ref == 'refs/heads/main' steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: fetch-tags: 'true' - - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 - with: + - name: Configure Go Proxy + uses: ./.github/actions/configure-goproxy + with: + user: ${{ secrets.ARTIFACTORY_USER }} + token: ${{ secrets.ARTIFACTORY_TOKEN }} + url: ${{ secrets.ARTIFACTORY_URL_DEV }} + - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 + with: go-version-file: 'go.mod' cache: false - - name: run goproxy-sanity-check - run: | - make build + - name: Download Go modules + run: go mod download + - name: Setup Build Environment + run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} + - name: Fix golang dependency permissions + run: chmod -R 0755 ~/go/pkg/mod ~/.cache/go-build + - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- lint: name: Lint @@ -54,84 +69,112 @@ jobs: url: ${{ secrets.ARTIFACTORY_URL_DEV }} - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 with: - go-version-file: 'go.mod' - cache: false + go-version-file: 'go.mod' + cache: false + - uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go- - name: Lint Go uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 with: version: v2.4.0 unit-test: - name: Unit Tests - runs-on: ubuntu-22.04 - permissions: - contents: write - steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Configure Go Proxy - uses: ./.github/actions/configure-goproxy - with: - user: ${{ secrets.ARTIFACTORY_USER }} - token: ${{ secrets.ARTIFACTORY_TOKEN }} - url: ${{ secrets.ARTIFACTORY_URL_DEV }} - - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 - with: - go-version-file: 'go.mod' - cache: false - - name: Run Unit Tests - run: make unit-test - - name: Uplaod Test Coverage - uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 - with: - files: ./build/test/coverage.out - token: ${{ secrets.CODECOV_TOKEN }} + name: Unit Tests + runs-on: ubuntu-22.04 + permissions: + contents: write + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - name: Configure Go Proxy + uses: ./.github/actions/configure-goproxy + with: + user: ${{ secrets.ARTIFACTORY_USER }} + token: ${{ secrets.ARTIFACTORY_TOKEN }} + url: ${{ secrets.ARTIFACTORY_URL_DEV }} + - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 + with: + go-version-file: 'go.mod' + cache: false + - uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go- + - name: Run Unit Tests + run: make unit-test + - name: Uplaod Test Coverage + uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 + with: + files: ./build/test/coverage.out + token: ${{ secrets.CODECOV_TOKEN }} race-condition-test: - name: Unit tests with race condition detection - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Configure Go Proxy - uses: ./.github/actions/configure-goproxy - with: - user: ${{ secrets.ARTIFACTORY_USER }} - token: ${{ secrets.ARTIFACTORY_TOKEN }} - url: ${{ secrets.ARTIFACTORY_URL_DEV }} - - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 - with: - go-version-file: 'go.mod' - cache: false - - name: Run unit tests with race condition detection - run: make race-condition-test + name: Unit tests with race condition detection + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - name: Configure Go Proxy + uses: ./.github/actions/configure-goproxy + with: + user: ${{ secrets.ARTIFACTORY_USER }} + token: ${{ secrets.ARTIFACTORY_TOKEN }} + url: ${{ secrets.ARTIFACTORY_URL_DEV }} + - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 + with: + go-version-file: 'go.mod' + cache: false + - uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go- + - 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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - fetch-tags: 'true' - - name: Configure Go Proxy - uses: ./.github/actions/configure-goproxy - with: - user: ${{ secrets.ARTIFACTORY_USER }} - token: ${{ secrets.ARTIFACTORY_TOKEN }} - url: ${{ secrets.ARTIFACTORY_URL_DEV }} - - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 - with: - go-version-file: 'go.mod' - cache: false - - name: Setup Build Environment - run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} - - name: Build Packages - run: | - make clean local-deb-package local-rpm-package local-apk-package - - name: Upload Artifacts - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: nginx-agent-unsigned-snapshots - path: build - retention-days: 1 + name: Build Unsigned Snapshot + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + fetch-tags: 'true' + - name: Configure Go Proxy + uses: ./.github/actions/configure-goproxy + with: + user: ${{ secrets.ARTIFACTORY_USER }} + token: ${{ secrets.ARTIFACTORY_TOKEN }} + url: ${{ secrets.ARTIFACTORY_URL_DEV }} + - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 + with: + go-version-file: 'go.mod' + cache: false + - name: Download Go modules + run: go mod download + - name: Setup Build Environment + run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} + - name: Fix golang dependency permissions + run: chmod -R 0755 ~/go/pkg/mod ~/.cache/go-build + - uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go- + - name: Build Packages + run: | + make clean local-deb-package local-rpm-package local-apk-package + - name: Upload Artifacts + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: nginx-agent-unsigned-snapshots + path: build + retention-days: 1 integration-tests: name: Integration Tests @@ -158,6 +201,12 @@ jobs: with: go-version-file: 'go.mod' cache: false + - uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go- - name: Download Packages uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 with: @@ -208,6 +257,12 @@ jobs: with: go-version-file: 'go.mod' cache: false + - uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go- - name: Download Packages uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 with: @@ -265,6 +320,12 @@ jobs: with: go-version-file: 'go.mod' cache: false + - uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go- - name: Download Packages uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 with: @@ -332,6 +393,12 @@ jobs: with: go-version-file: 'go.mod' cache: false + - uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go- - name: Download Packages uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 with: @@ -398,6 +465,12 @@ jobs: with: go-version-file: 'go.mod' cache: false + - uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go- - name: Download Packages uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 with: @@ -465,6 +538,12 @@ jobs: with: go-version-file: 'go.mod' cache: false + - uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go- - name: Download Packages uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 with: @@ -502,6 +581,7 @@ jobs: performance-tests: name: Performance Tests runs-on: ubuntu-22.04 + needs: build-unsigned-snapshot permissions: contents: write steps: @@ -516,6 +596,12 @@ jobs: with: go-version-file: 'go.mod' cache: false + - uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go- - name: Run Performance Tests run: | make performance-test @@ -534,6 +620,7 @@ jobs: - name: Push benchmark result 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 if: ${{ !github.event.pull_request.head.repo.fork && !startsWith(github.head_ref, 'dependabot-') }} @@ -541,7 +628,6 @@ jobs: contents: write runs-on: ubuntu-22.04 needs: build-unsigned-snapshot - steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 @@ -549,6 +635,13 @@ jobs: go-version-file: 'go.mod' cache: false + - uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go- + - name: Download Packages uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 with: diff --git a/go.mod b/go.mod index 39ad720a8..1c324f9cb 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.9-20250912141014-52f32327d4b0.1 buf.build/go/protovalidate v1.0.0 github.com/cenkalti/backoff/v4 v4.3.0 - github.com/docker/docker v28.4.0+incompatible + github.com/docker/docker v28.5.1+incompatible github.com/fsnotify/fsnotify v1.9.0 github.com/go-resty/resty/v2 v2.16.5 github.com/goccy/go-yaml v1.18.0 @@ -42,7 +42,7 @@ require ( github.com/shirou/gopsutil/v4 v4.25.9 github.com/spf13/pflag v1.0.10 github.com/stretchr/testify v1.11.1 - github.com/testcontainers/testcontainers-go v0.39.0 + github.com/testcontainers/testcontainers-go v0.40.0 github.com/trivago/grok v1.0.0 go.opentelemetry.io/collector/component v1.45.0 go.opentelemetry.io/collector/component/componenttest v0.139.0 diff --git a/go.sum b/go.sum index 0ecee6728..c69b1a1b6 100644 --- a/go.sum +++ b/go.sum @@ -164,8 +164,8 @@ github.com/digitalocean/godo v1.165.1 h1:H37+W7TaGFOVH+HpMW4ZeW/hrq3AGNxg+B/K8/d github.com/digitalocean/godo v1.165.1/go.mod h1:xQsWpVCCbkDrWisHA72hPzPlnC+4W5w/McZY5ij9uvU= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/docker v28.4.0+incompatible h1:KVC7bz5zJY/4AZe/78BIvCnPsLaC9T/zh72xnlrTTOk= -github.com/docker/docker v28.4.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v28.5.1+incompatible h1:Bm8DchhSD2J6PsFzxC35TZo4TLGR2PdW/E69rU45NhM= +github.com/docker/docker v28.5.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.6.0 h1:LlMG9azAe1TqfR7sO+NJttz1gy6KO7VJBh+pMmjSD94= github.com/docker/go-connections v0.6.0/go.mod h1:AahvXYshr6JgfUJGdDCs2b5EZG/vmaMAntpSFH5BFKE= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -711,8 +711,8 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= -github.com/testcontainers/testcontainers-go v0.39.0 h1:uCUJ5tA+fcxbFAB0uP3pIK3EJ2IjjDUHFSZ1H1UxAts= -github.com/testcontainers/testcontainers-go v0.39.0/go.mod h1:qmHpkG7H5uPf/EvOORKvS6EuDkBUPE3zpVGaH9NL7f8= +github.com/testcontainers/testcontainers-go v0.40.0 h1:pSdJYLOVgLE8YdUY2FHQ1Fxu+aMnb6JfVz1mxk7OeMU= +github.com/testcontainers/testcontainers-go v0.40.0/go.mod h1:FSXV5KQtX2HAMlm7U3APNyLkkap35zNLxukw9oBi/MY= github.com/tilinna/clock v1.1.0 h1:6IQQQCo6KoBxVudv6gwtY8o4eDfhHo8ojA5dP0MfhSs= github.com/tilinna/clock v1.1.0/go.mod h1:ZsP7BcY7sEEz7ktc0IVy8Us6boDrK8VradlKRUGfOao= github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4=