From af200cf3a721d271bf8e564128f12e02beccaf39 Mon Sep 17 00:00:00 2001 From: xander Date: Mon, 30 Dec 2024 16:53:55 +0000 Subject: [PATCH 1/2] Latest upstream GH workflows --- .github/workflows/build-and-test-arm.yml | 7 +- .github/workflows/build-and-test-darwin.yaml | 100 ++++++++++++++ .github/workflows/build-and-test-windows.yml | 10 +- .github/workflows/build-and-test.yml | 122 +++++------------ .github/workflows/changelog.yml | 2 +- .github/workflows/codeql-analysis.yml | 3 +- .github/workflows/e2e-tests-windows.yml | 129 ++++++++++++++++++ .github/workflows/e2e-tests.yml | 12 +- .github/workflows/load-tests.yml | 5 +- .github/workflows/prepare-release.yml | 2 +- .../workflows/prometheus-compliance-tests.yml | 16 ++- .github/workflows/scripts/add-labels.sh | 7 +- .../scripts/release-prepare-release.sh | 15 +- .../scripts/verify-dist-files-exist.sh | 8 -- .../workflows/scripts/win-required-ports.ps1 | 20 +++ .github/workflows/telemetrygen.yml | 6 +- .github/workflows/tidy-dependencies.yml | 2 +- 17 files changed, 342 insertions(+), 124 deletions(-) create mode 100644 .github/workflows/build-and-test-darwin.yaml create mode 100644 .github/workflows/e2e-tests-windows.yml create mode 100644 .github/workflows/scripts/win-required-ports.ps1 diff --git a/.github/workflows/build-and-test-arm.yml b/.github/workflows/build-and-test-arm.yml index c565b251f7b5..285a79e222aa 100644 --- a/.github/workflows/build-and-test-arm.yml +++ b/.github/workflows/build-and-test-arm.yml @@ -14,7 +14,6 @@ env: # Make sure to exit early if cache segment download times out after 2 minutes. # We limit cache download as a whole to 5 minutes. SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 - GOPROXY: https://goproxy1.cncf.selfactuated.dev,direct # Do not cancel this workflow on main. See https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/16616 concurrency: @@ -46,7 +45,7 @@ jobs: - cmd-1 - other timeout-minutes: 30 - runs-on: actuated-arm64-4cpu-4gb + runs-on: otel-linux-arm64 steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 @@ -61,7 +60,7 @@ jobs: path: | ~/go/bin ~/go/pkg/mod - key: go-build-cache-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + key: go-build-cache-otel-linux-arm64-go-${{ hashFiles('**/go.sum') }} - name: Install dependencies if: steps.go-cache.outputs.cache-hit != 'true' run: make -j2 gomoddownload @@ -72,7 +71,7 @@ jobs: run: make -j2 gotest GROUP=${{ matrix.group }} arm-unittest: if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run ARM') || github.event_name == 'push' || github.event_name == 'merge_group') }} - runs-on: actuated-arm64-4cpu-4gb + runs-on: ubuntu-latest needs: [arm-unittest-matrix] steps: - name: Print result diff --git a/.github/workflows/build-and-test-darwin.yaml b/.github/workflows/build-and-test-darwin.yaml new file mode 100644 index 000000000000..6ae971b84192 --- /dev/null +++ b/.github/workflows/build-and-test-darwin.yaml @@ -0,0 +1,100 @@ +name: build-and-test-darwin +on: + push: + branches: [main] + tags: + - "v[0-9]+.[0-9]+.[0-9]+*" + merge_group: + pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled] + branches: + - main +env: + TEST_RESULTS: testbed/tests/results/junit/results.xml + # Make sure to exit early if cache segment download times out after 2 minutes. + # We limit cache download as a whole to 5 minutes. + SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 + +# Do not cancel this workflow on main. See https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/16616 +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + darwin-build-unittest-binary: + if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Darwin') || github.event_name == 'push' || github.event_name == 'merge_group') }} + runs-on: macos-14 + timeout-minutes: 120 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "~1.22.5" + cache: false + - name: Cache Go + id: go-cache + timeout-minutes: 5 + uses: actions/cache@v4 + with: + path: | + ~/go/bin + ~/go/pkg/mod + key: go-build-cache-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + - name: Install dependencies + if: steps.go-cache.outputs.cache-hit != 'true' + run: make -j2 gomoddownload + - name: Install Tools + if: steps.go-cache.outputs.cache-hit != 'true' + run: make install-tools + - name: Build test binaries + env: + GOTESTARCH: amd64 + run: make gobuildtest GROUP=cgo + - name: Zip test binaries + run: zip -r testbinaries.zip . --include \*builtunitetest.test + - uses: actions/upload-artifact@v4 + with: + name: testbinaries + path: ./testbinaries.zip + retention-days: 1 + darwin-unittest-matrix: + if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Darwin') || github.event_name == 'push' || github.event_name == 'merge_group') }} + needs: [darwin-build-unittest-binary] + strategy: + fail-fast: false + matrix: + os: [macos-12, macos-13] + timeout-minutes: 30 + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "~1.22.5" + cache: false + - name: Install Tools + if: steps.go-cache.outputs.cache-hit != 'true' + run: make install-tools + - uses: actions/download-artifact@v4 + with: + name: testbinaries + - name: Unzip binaries to each module + run: unzip testbinaries.zip + - name: Run Unit Tests + run: make -j2 gorunbuilttest GROUP=cgo + darwin-unittest: + if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Darwin') || github.event_name == 'push' || github.event_name == 'merge_group') }} + runs-on: macos-latest + needs: [darwin-unittest-matrix] + steps: + - name: Print result + run: echo ${{ needs.darwin-unittest-matrix.result }} + - name: Interpret result + run: | + if [[ success == ${{ needs.darwin-unittest-matrix.result }} ]] + then + echo "All matrix jobs passed!" + else + echo "One or more matrix jobs failed." + false + fi diff --git a/.github/workflows/build-and-test-windows.yml b/.github/workflows/build-and-test-windows.yml index cbd66e20d7a2..dafbfe3838a8 100644 --- a/.github/workflows/build-and-test-windows.yml +++ b/.github/workflows/build-and-test-windows.yml @@ -58,7 +58,7 @@ jobs: run: Install-WindowsFeature -name Web-Server -IncludeManagementTools - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-mod-cache @@ -69,6 +69,14 @@ jobs: ~\go\pkg\mod ~\AppData\Local\go-build key: go-build-cache-${{ runner.os }}-${{ matrix.group }}-go-${{ hashFiles('**/go.sum') }} + - name: Ensure required ports in the dynamic range are available + run: | + & ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1 + - name: Build shared test tools + # If component tests share Makefile targets they need to be added here to avoid + # concurrent component tests clashing when building such targets. This applies + # specifically to Windows, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/34691 + run: make "$(${PWD} -replace '\\', '/')/.tools/gotestsum" - name: Run Unit tests run: make -j2 gotest GROUP=${{ matrix.group }} windows-unittest: diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 43957a173192..ae5bcac79ed5 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -36,6 +36,7 @@ jobs: path: | ~/go/bin ~/go/pkg/mod + ./.tools key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} - name: Install dependencies if: steps.go-cache.outputs.cache-hit != 'true' @@ -48,6 +49,7 @@ jobs: needs: [setup-environment] steps: - uses: actions/checkout@v4 + - run: make genotelcontribcol - name: Check Collector Module Version run: ./.github/workflows/scripts/check-collector-module-version.sh check-codeowners: @@ -65,7 +67,7 @@ jobs: strategy: fail-fast: false matrix: - test: + goos: - windows - linux group: @@ -92,7 +94,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -102,6 +104,7 @@ jobs: path: | ~/go/bin ~/go/pkg/mod + ./.tools key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} - name: Install dependencies if: steps.go-cache.outputs.cache-hit != 'true' @@ -115,7 +118,7 @@ jobs: path: ~/.cache/go-build key: go-lint-build-${{ matrix.group }}-${{ runner.os }}-${{ hashFiles('**/go.sum') }} - name: Lint - run: GOOS=${{ matrix.os }} GOARCH=amd64 make -j2 golint GROUP=${{ matrix.group }} + run: GOOS=${{ matrix.goos }} GOARCH=amd64 make -j2 golint GROUP=${{ matrix.group }} lint: if: ${{ github.actor != 'dependabot[bot]' && always() }} runs-on: ubuntu-latest @@ -161,7 +164,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -171,6 +174,7 @@ jobs: path: | ~/go/bin ~/go/pkg/mod + ./.tools key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} - name: Install Tools if: steps.go-cache.outputs.cache-hit != 'true' @@ -184,7 +188,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -194,6 +198,7 @@ jobs: path: | ~/go/bin ~/go/pkg/mod + ./.tools key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} - name: Install dependencies if: steps.go-cache.outputs.cache-hit != 'true' @@ -201,6 +206,7 @@ jobs: - name: Install Tools if: steps.go-cache.outputs.cache-hit != 'true' run: make install-tools + - run: make genotelcontribcol - name: CheckDoc run: make checkdoc - name: CheckMetadata @@ -219,14 +225,6 @@ jobs: run: | make gotidy git diff --exit-code || (echo 'go.mod/go.sum deps changes detected, please run "make gotidy" and commit the changes in this PR.' && exit 1) - - name: Gen genotelcontribcol - run: | - make genotelcontribcol - git diff -s --exit-code || (echo 'Generated code is out of date, please run "make genotelcontribcol" and commit the changes in this PR.' && exit 1) - - name: Gen genoteltestbedcol - run: | - make genoteltestbedcol - git diff -s --exit-code || (echo 'Generated code is out of date, please run "make genoteltestbedcol" and commit the changes in this PR.' && exit 1) - name: Gen distributions run: | make gendistributions @@ -253,7 +251,7 @@ jobs: strategy: fail-fast: false matrix: - go-version: ["1.22.5", "1.21.12"] # 1.20 is interpreted as 1.2 without quotes + go-version: ["1.23.0", "1.22.8"] # 1.20 is interpreted as 1.2 without quotes runner: [ubuntu-latest] group: - receiver-0 @@ -289,6 +287,7 @@ jobs: path: | ~/go/bin ~/go/pkg/mod + ./.tools key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} - name: Install dependencies if: steps.go-cache.outputs.cache-hit != 'true' @@ -302,13 +301,13 @@ jobs: path: ~/.cache/go-build key: go-test-build-${{ runner.os }}-${{ matrix.go-version }}-${{ matrix.runner }}-${{ hashFiles('**/go.sum') }} - name: Run Unit Tests - if: startsWith( matrix.go-version, '1.21' ) != true + if: startsWith( matrix.go-version, '1.22' ) != true run: make gotest GROUP=${{ matrix.group }} - name: Run Unit Tests With Coverage - if: startsWith( matrix.go-version, '1.21' ) # only run coverage on one version + if: startsWith( matrix.go-version, '1.22' ) # only run coverage on one version run: make gotest-with-cover GROUP=${{ matrix.group }} - uses: actions/upload-artifact@v4 - if: startsWith( matrix.go-version, '1.21' ) # only upload artifact for one version + if: startsWith( matrix.go-version, '1.22' ) # only upload artifact for one version with: name: coverage-artifacts-${{ matrix.go-version }}-${{ matrix.runner }}-${{ matrix.group }} path: ${{ matrix.group }}-coverage.txt @@ -338,7 +337,7 @@ jobs: merge-multiple: true pattern: coverage-artifacts-* - name: Upload coverage report - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # 4.5.0 + uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # 4.6.0 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} @@ -369,7 +368,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -379,6 +378,7 @@ jobs: path: | ~/go/bin ~/go/pkg/mod + ./.tools key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} - name: Run Integration Tests run: make gointegration-test GROUP=${{ matrix.group }} @@ -407,7 +407,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -417,6 +417,7 @@ jobs: path: | ~/go/bin ~/go/pkg/mod + ./.tools key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} - name: Install dependencies if: steps.go-cache.outputs.cache-hit != 'true' @@ -433,7 +434,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -443,6 +444,7 @@ jobs: path: | ~/go/bin ~/go/pkg/mod + ./.tools key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} - name: Install dependencies if: steps.go-cache.outputs.cache-hit != 'true' @@ -458,6 +460,7 @@ jobs: needs: [setup-environment] steps: - uses: actions/checkout@v4 + - run: make genotelcontribcol - name: Build Examples run: make build-examples @@ -503,7 +506,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -513,6 +516,7 @@ jobs: path: | ~/go/bin ~/go/pkg/mod + ./.tools key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} - name: Install dependencies if: steps.go-cache.outputs.cache-hit != 'true' @@ -520,6 +524,8 @@ jobs: - name: Install Tools if: steps.go-cache.outputs.cache-hit != 'true' run: make install-tools + - name: Generate collector files + run: make genotelcontribcol - name: Build Collector ${{ matrix.binary }} run: make GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} GOARM=${{ matrix.arm }} otelcontribcol - name: Upload Collector Binaries @@ -528,57 +534,9 @@ jobs: name: collector-binaries-${{ matrix.os }}-${{ matrix.arch }} path: ./bin/* - build-package: - runs-on: ubuntu-latest - needs: [cross-compile] - strategy: - fail-fast: false - matrix: - package_type: ["deb", "rpm"] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Install Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.3" - - name: Install fpm - run: gem install --no-document fpm -v 1.15.1 - - name: Download Collector Binaries - uses: actions/download-artifact@v4 - with: - merge-multiple: true - path: bin/ - pattern: collector-binaries-* - - run: chmod +x bin/* - - name: Set Release Tag - id: github_tag - run: ./.github/workflows/scripts/set_release_tag.sh - - name: Build ${{ matrix.package_type }} amd64 package - run: ./internal/buildscripts/packaging/fpm/${{ matrix.package_type }}/build.sh "${{ steps.github_tag.outputs.tag }}" "amd64" "./dist/" - - name: Build ${{ matrix.package_type }} arm64 package - run: ./internal/buildscripts/packaging/fpm/${{ matrix.package_type }}/build.sh "${{ steps.github_tag.outputs.tag }}" "arm64" "./dist/" - - name: Build ${{ matrix.package_type }} ppc64le package - run: ./internal/buildscripts/packaging/fpm/${{ matrix.package_type }}/build.sh "${{ steps.github_tag.outputs.tag }}" "ppc64le" "./dist/" - - name: Build ${{ matrix.package_type }} s390x package - run: ./internal/buildscripts/packaging/fpm/${{ matrix.package_type }}/build.sh "${{ steps.github_tag.outputs.tag }}" "s390x" "./dist/" - - name: Test ${{ matrix.package_type }} package - run: | - if [[ "${{ matrix.package_type }}" = "deb" ]]; then - ./internal/buildscripts/packaging/fpm/test.sh dist/otel-contrib-collector*amd64.deb examples/demo/otel-collector-config.yaml - else - ./internal/buildscripts/packaging/fpm/test.sh dist/otel-contrib-collector*x86_64.rpm examples/demo/otel-collector-config.yaml - fi - - name: Upload Packages - uses: actions/upload-artifact@v4 - with: - name: collector-packages-${{ matrix.package_type }} - path: ./dist/* - publish-check: runs-on: ubuntu-latest - needs: [lint, unittest, integration-tests, build-package] + needs: [lint, unittest, integration-tests] steps: - uses: actions/checkout@v4 - name: Download Binaries @@ -587,24 +545,18 @@ jobs: merge-multiple: true path: ./bin/ pattern: collector-binaries-* - - name: Download Packages - uses: actions/download-artifact@v4 - with: - merge-multiple: true - path: ./dist/ - pattern: collector-packages-* - name: Verify Distribution Files Exist id: check run: ./.github/workflows/scripts/verify-dist-files-exist.sh publish-dev: runs-on: ubuntu-latest - needs: [lint, unittest, integration-tests, build-package] + needs: [lint, unittest, integration-tests] if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && github.repository == 'open-telemetry/opentelemetry-collector-contrib' steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Mkdir bin and dist run: | @@ -617,6 +569,7 @@ jobs: path: | ~/go/bin ~/go/pkg/mod + ./.tools key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} - name: Install dependencies if: steps.go-cache.outputs.cache-hit != 'true' @@ -631,12 +584,6 @@ jobs: path: ./bin/ pattern: collector-binaries-* - run: chmod +x bin/* - - name: Download Packages - uses: actions/download-artifact@v4 - with: - merge-multiple: true - path: ./dist/ - pattern: collector-packages-* - name: Add Permissions to Tool Binaries run: chmod -R +x ./dist - name: Verify Distribution Files Exist @@ -645,6 +592,7 @@ jobs: - name: Build Docker Image if: steps.check.outputs.passed == 'true' run: | + make genotelcontribcol make docker-otelcontribcol docker tag otelcontribcol:latest otel/opentelemetry-collector-contrib-dev:$GITHUB_SHA docker tag otelcontribcol:latest otel/opentelemetry-collector-contrib-dev:latest @@ -665,7 +613,7 @@ jobs: docker push otel/opentelemetry-collector-contrib-dev:latest publish-stable: runs-on: ubuntu-latest - needs: [lint, unittest, integration-tests, build-package] + needs: [lint, unittest, integration-tests] if: startsWith(github.ref, 'refs/tags/v') && github.repository == 'open-telemetry/opentelemetry-collector-contrib' steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index aa6b258b4a59..468dbb930d15 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -33,7 +33,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index a3fbec79f5ee..8769d26452c7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false # Initializes the CodeQL tools for scanning. @@ -31,6 +31,7 @@ jobs: - name: Build Artifact run: | + make genotelcontribcol make otelcontribcol - name: Perform CodeQL Analysis diff --git a/.github/workflows/e2e-tests-windows.yml b/.github/workflows/e2e-tests-windows.yml new file mode 100644 index 000000000000..0745599b555f --- /dev/null +++ b/.github/workflows/e2e-tests-windows.yml @@ -0,0 +1,129 @@ +name: e2e-tests-windows + +on: + push: + branches: + - main + tags: + - "v[0-9]+.[0-9]+.[0-9]+*" + paths-ignore: + - "**/README.md" + pull_request: + paths-ignore: + - "**/README.md" + merge_group: + +env: + # Make sure to exit early if cache segment download times out after 2 minutes. + # We limit cache download as a whole to 5 minutes. + SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 + +jobs: + collector-build: + runs-on: windows-latest + if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Windows') || github.event_name == 'push' || github.event_name == 'merge_group') }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.21.12" + cache: false + - name: Cache Go + id: go-mod-cache + timeout-minutes: 25 + uses: actions/cache@v4 + with: + path: | + ~\go\pkg\mod + ~\AppData\Local\go-build + key: go-build-cache-${{ runner.os }}-${{ matrix.group }}-go-${{ hashFiles('**/go.sum') }} + - name: Install dependencies + if: steps.go-mod-cache.outputs.cache-hit != 'true' + run: make -j2 gomoddownload + - name: Generate otelcontribcol files + run: make genotelcontribcol + - name: Build Collector + run: make otelcontribcol + - name: Upload Collector Binary + uses: actions/upload-artifact@v4 + with: + name: collector-binary + path: ./bin/* + + supervisor-test: + runs-on: windows-latest + if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Windows') || github.event_name == 'push' || github.event_name == 'merge_group') }} + needs: [collector-build] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.21.12" + cache: false + - name: Cache Go + id: go-mod-cache + timeout-minutes: 25 + uses: actions/cache@v4 + with: + path: | + ~\go\pkg\mod + ~\AppData\Local\go-build + key: go-build-cache-${{ runner.os }}-${{ matrix.group }}-go-${{ hashFiles('**/go.sum') }} + - name: Install dependencies + if: steps.go-mod-cache.outputs.cache-hit != 'true' + run: make -j2 gomoddownload + - name: Download Collector Binary + uses: actions/download-artifact@v4 + with: + name: collector-binary + path: bin/ + - name: Run opampsupervisor e2e tests + run: | + cd cmd/opampsupervisor + go test -v --tags=e2e + + windows-supervisor-service-test: + runs-on: windows-latest + if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Windows') || github.event_name == 'push' || github.event_name == 'merge_group') }} + needs: [collector-build] + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ~1.22.8 + cache: false + - name: Cache Go + uses: actions/cache@v4 + env: + cache-name: cache-go-modules + with: + path: | + ~\go\pkg\mod + ~\AppData\Local\go-build + key: go-build-cache-${{ runner.os }}-${{ matrix.group }}-go-${{ hashFiles('**/go.sum') }} + - name: Ensure required ports in the dynamic range are available + run: | + & ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1 + - name: Download Collector Binary + uses: actions/download-artifact@v4 + with: + name: collector-binary + path: bin/ + - name: Build supervisor + run: cd cmd/opampsupervisor; go build + - name: Install supervisor as a service + run: | + New-Service -Name "opampsupervisor" -StartupType "Manual" -BinaryPathName "${PWD}\cmd\opampsupervisor --config ${PWD}\cmd\opampsupervisor\supervisor\testdata\supervisor_windows_service_test_config.yaml\" + eventcreate.exe /t information /id 1 /l application /d "Creating event provider for 'opampsupervisor'" /so opampsupervisor + - name: Test supervisor service + working-directory: ${{ github.workspace }}/cmd/opampsupervisor + run: | + go test -timeout 90s -run ^TestSupervisorAsService$ -v -tags=win32service + - name: Remove opampsupervisor service + if: always() + run: | + Remove-Service opampsupervisor + Remove-Item HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\Application\opampsupervisor diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index b16facd8ad49..865b45366147 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -40,6 +40,8 @@ jobs: - name: Install dependencies if: steps.go-cache.outputs.cache-hit != 'true' run: make -j2 gomoddownload + - name: Generate otelcontribcol files + run: make genotelcontribcol - name: Build Collector run: make otelcontribcol - name: Upload Collector Binary @@ -55,7 +57,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -87,7 +89,7 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -101,6 +103,8 @@ jobs: - name: Install dependencies if: steps.go-cache.outputs.cache-hit != 'true' run: make -j2 gomoddownload + - name: Generate otelcontribcol files + run: make genotelcontribcol - name: Build Docker Image run: | make docker-otelcontribcol @@ -133,7 +137,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache diff --git a/.github/workflows/load-tests.yml b/.github/workflows/load-tests.yml index 349e0499e1c6..d6e50cec4f92 100644 --- a/.github/workflows/load-tests.yml +++ b/.github/workflows/load-tests.yml @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -46,6 +46,7 @@ jobs: - name: Install Tools if: steps.go-cache.outputs.cache-hit != 'true' run: make install-tools + - run: make genoteltestbedcol - run: make oteltestbedcol - name: Upload Testbed Binaries uses: actions/upload-artifact@v4 @@ -66,7 +67,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index ecc205d2935a..597f6e3ff2af 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -26,7 +26,7 @@ jobs: path: opentelemetry-collector-contrib - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Prepare release for contrib working-directory: opentelemetry-collector-contrib diff --git a/.github/workflows/prometheus-compliance-tests.yml b/.github/workflows/prometheus-compliance-tests.yml index 51267762c924..9557274a088f 100644 --- a/.github/workflows/prometheus-compliance-tests.yml +++ b/.github/workflows/prometheus-compliance-tests.yml @@ -31,7 +31,7 @@ jobs: path: opentelemetry-collector-contrib - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -42,7 +42,10 @@ jobs: ~/go/bin ~/go/pkg/mod ~/.cache/go-build + ./.tools key: prometheus-${{ runner.os }}-go-${{ hashFiles('**/go.mod', '**/go.sum') }} + - run: make genotelcontribcol + working-directory: opentelemetry-collector-contrib - run: make otelcontribcol working-directory: opentelemetry-collector-contrib - name: Checkout compliance repo @@ -53,7 +56,12 @@ jobs: - name: Copy binary to compliance directory # The required name of the downloaded artifact is `otelcol_0.42.0_linux_amd64`, so we place the collector contrib artifact under the same name in the bin folder to run. # Source: https://github.com/prometheus/compliance/blob/12cbdf92abf7737531871ab7620a2de965fc5382/remote_write_sender/targets/otel.go#L8 - run: mkdir compliance/remote_write_sender/bin && cp opentelemetry-collector-contrib/bin/otelcontribcol_linux_amd64 compliance/remote_write_sender/bin/otelcol_0.42.0_linux_amd64 + run: mkdir compliance/remotewrite/sender/bin && cp opentelemetry-collector-contrib/bin/otelcontribcol_linux_amd64 compliance/remotewrite/sender/bin/otelcol_0.42.0_linux_amd64 + - name: clean up mod file + run: go mod tidy + working-directory: compliance/remotewrite/sender - name: Run compliance tests - run: go test -v --tags=compliance -run "TestRemoteWrite/otel/.+" ./ |& tee ./test-report.txt - working-directory: compliance/remote_write_sender + run: | + set -o pipefail && \ + go test -v --tags=compliance -run "TestRemoteWrite/otel/.+" ./ |& tee ./test-report.txt + working-directory: compliance/remotewrite/sender diff --git a/.github/workflows/scripts/add-labels.sh b/.github/workflows/scripts/add-labels.sh index 93d081abaa45..6b8f33bde154 100755 --- a/.github/workflows/scripts/add-labels.sh +++ b/.github/workflows/scripts/add-labels.sh @@ -20,18 +20,23 @@ if [[ ${COMMENT:0:6} != "/label" ]]; then fi declare -A COMMON_LABELS +COMMON_LABELS["arm64"]="arm64" COMMON_LABELS["good-first-issue"]="good first issue" COMMON_LABELS["help-wanted"]="help wanted" COMMON_LABELS["needs-discussion"]="needs discussion" COMMON_LABELS["needs-triage"]="needs triage" +COMMON_LABELS["os:mac"]="os:mac" +COMMON_LABELS["os:windows"]="os:windows" COMMON_LABELS["waiting-for-author"]="waiting for author" LABELS=$(echo "${COMMENT}" | sed -E 's%^/label%%') for LABEL_REQ in ${LABELS}; do LABEL=$(echo "${LABEL_REQ}" | sed -E s/^[+-]?//) - SHOULD_ADD=true + # Trim newlines from label that would cause matching to fail + LABEL=$(echo "${LABEL}" | tr -d '\n') + SHOULD_ADD=true if [[ "${LABEL_REQ:0:1}" = "-" ]]; then SHOULD_ADD=false fi diff --git a/.github/workflows/scripts/release-prepare-release.sh b/.github/workflows/scripts/release-prepare-release.sh index 23f349b28f1e..4f6ebb155aec 100755 --- a/.github/workflows/scripts/release-prepare-release.sh +++ b/.github/workflows/scripts/release-prepare-release.sh @@ -16,6 +16,9 @@ then exit 1 fi +# Expand CURRENT_BETA to escape . character by using [.] +CURRENT_BETA_ESCAPED=${CURRENT_BETA//./[.]} + make chlog-update VERSION="v${CANDIDATE_BETA}" git config user.name opentelemetrybot git config user.email 107717825+opentelemetrybot@users.noreply.github.com @@ -25,15 +28,15 @@ git checkout -b "${BRANCH}" git add --all git commit -m "changelog update ${CANDIDATE_BETA}" -sed -i.bak "s/${CURRENT_BETA}/${CANDIDATE_BETA}/g" versions.yaml +sed -i.bak "s/${CURRENT_BETA_ESCAPED}/${CANDIDATE_BETA}/g" versions.yaml find . -name "*.bak" -type f -delete git add versions.yaml git commit -m "update version.yaml ${CANDIDATE_BETA}" -sed -i.bak "s/v${CURRENT_BETA}/v${CANDIDATE_BETA}/g" ./cmd/oteltestbedcol/builder-config.yaml -sed -i.bak "s/v${CURRENT_BETA}/v${CANDIDATE_BETA}/g" ./cmd/otelcontribcol/builder-config.yaml -sed -i.bak "s/${CURRENT_BETA}-dev/${CANDIDATE_BETA}-dev/g" ./cmd/otelcontribcol/builder-config.yaml -sed -i.bak "s/${CURRENT_BETA}-dev/${CANDIDATE_BETA}-dev/g" ./cmd/oteltestbedcol/builder-config.yaml +sed -i.bak "s/v${CURRENT_BETA_ESCAPED}/v${CANDIDATE_BETA}/g" ./cmd/oteltestbedcol/builder-config.yaml +sed -i.bak "s/v${CURRENT_BETA_ESCAPED}/v${CANDIDATE_BETA}/g" ./cmd/otelcontribcol/builder-config.yaml +sed -i.bak "s/${CURRENT_BETA_ESCAPED}-dev/${CANDIDATE_BETA}-dev/g" ./cmd/otelcontribcol/builder-config.yaml +sed -i.bak "s/${CURRENT_BETA_ESCAPED}-dev/${CANDIDATE_BETA}-dev/g" ./cmd/oteltestbedcol/builder-config.yaml find . -name "*.bak" -type f -delete make genotelcontribcol @@ -64,7 +67,7 @@ git push origin "${BRANCH}" gh pr create --title "[chore] Prepare release ${CANDIDATE_BETA}" --body " The following commands were run to prepare this release: - make chlog-update VERSION=v${CANDIDATE_BETA} -- sed -i.bak s/${CURRENT_BETA}/${CANDIDATE_BETA}/g versions.yaml +- sed -i.bak s/${CURRENT_BETA_ESCAPED}/${CANDIDATE_BETA}/g versions.yaml - make multimod-prerelease - make multimod-sync " diff --git a/.github/workflows/scripts/verify-dist-files-exist.sh b/.github/workflows/scripts/verify-dist-files-exist.sh index 4db111a94c7a..06b07e8e4bca 100755 --- a/.github/workflows/scripts/verify-dist-files-exist.sh +++ b/.github/workflows/scripts/verify-dist-files-exist.sh @@ -11,14 +11,6 @@ files=( bin/otelcontribcol_linux_amd64 bin/otelcontribcol_linux_s390x bin/otelcontribcol_windows_amd64.exe - dist/otel-contrib-collector-*.aarch64.rpm - dist/otel-contrib-collector_*_amd64.deb - dist/otel-contrib-collector-*.x86_64.rpm - dist/otel-contrib-collector_*_arm64.deb - dist/otel-contrib-collector-*.ppc64le.rpm - dist/otel-contrib-collector_*_ppc64le.deb - dist/otel-contrib-collector_*_s390x.deb - dist/otel-contrib-collector-*.s390x.rpm # skip. See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/10113 # dist/otel-contrib-collector-*amd64.msi diff --git a/.github/workflows/scripts/win-required-ports.ps1 b/.github/workflows/scripts/win-required-ports.ps1 new file mode 100644 index 000000000000..ef209792de8d --- /dev/null +++ b/.github/workflows/scripts/win-required-ports.ps1 @@ -0,0 +1,20 @@ +<# +.SYNOPSIS + This script ensures that the ports required by the default configuration of the collector are available. +.DESCRIPTION + Certain runs on GitHub Actions sometimes have ports required by the default configuration reserved by other + applications via the WinNAT service. +#> + +#Requires -RunAsAdministrator + +netsh interface ip show excludedportrange protocol=tcp + +Stop-Service winnat + +# Only port in the dynamic range that is being, from time to time, reserved by other applications. +netsh interface ip add excludedportrange protocol=tcp startport=55678 numberofports=2 + +Start-Service winnat + +netsh interface ip show excludedportrange protocol=tcp diff --git a/.github/workflows/telemetrygen.yml b/.github/workflows/telemetrygen.yml index 0a800e383555..555820eb1c6b 100644 --- a/.github/workflows/telemetrygen.yml +++ b/.github/workflows/telemetrygen.yml @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -67,7 +67,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache @@ -112,7 +112,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache diff --git a/.github/workflows/tidy-dependencies.yml b/.github/workflows/tidy-dependencies.yml index 3b8a71248e35..8853bf3ed097 100644 --- a/.github/workflows/tidy-dependencies.yml +++ b/.github/workflows/tidy-dependencies.yml @@ -21,7 +21,7 @@ jobs: ref: ${{ github.head_ref }} - uses: actions/setup-go@v5 with: - go-version: "1.21.12" + go-version: "1.22.8" cache: false - name: Cache Go id: go-cache From 11f67b003144e5837c1560292486cc55103bfa0a Mon Sep 17 00:00:00 2001 From: xander Date: Thu, 2 Jan 2025 11:16:06 +0000 Subject: [PATCH 2/2] Test making workflow trigger --- .github/workflows/publish.yml | 119 ++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000000..0bf8cf88a9a7 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,119 @@ +name: publish +on: + workflow_run: + types: + - completed + workflows: + - build-and-test +jobs: + publish-dev: + permissions: + contents: 'read' + id-token: 'write' + runs-on: ubuntu-latest + if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: "1.21.12" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Mkdir bin and dist + run: | + mkdir bin/ dist/ + - name: Cache Go + id: go-cache + uses: actions/cache@v3 + with: + path: | + ~/go/bin + ~/go/pkg/mod + key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} + - name: Install dependencies + if: steps.go-cache.outputs.cache-hit != 'true' + run: make -j2 gomoddownload + - name: Install Tools + if: steps.go-cache.outputs.cache-hit != 'true' + run: make install-tools + - name: Download Binaries + uses: actions/download-artifact@v3 + with: + name: collector-binaries + path: ./bin/ + - run: chmod +x bin/* + - name: Sanitize branch name and create version + id: create-version + env: + BRANCH: ${{github.ref_name}} + RUN_NUMBER: ${{github.run_number}} + BASE_VERSION: "0.0.0" + run: | + # let's simply use the k8s namespace rules (even stricter) and have the same version(-suffix) for everything + # lowercase everything and replace all invalid characters with '-' and trim to 60 characters + SANITIZED_BRANCH=$(echo -n "${BRANCH}" | tr '[:upper:]' '[:lower:]' | tr -C 'a-z0-9' '-') + SANITIZED_BRANCH="${SANITIZED_BRANCH:0:60}" + + BUILD_VERSION="${BASE_VERSION}-${SANITIZED_BRANCH}-${RUN_NUMBER}" + echo "BUILD_VERSION=${BUILD_VERSION}" | tee -a $GITHUB_ENV $GITHUB_OUTPUT + - id: login-azure + name: Authenticate with Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + - name: Login to Azure Artifact Registry + shell: bash + run: | + az acr login -n dataplanedeployment + - id: login-gcp + name: Authenticate with Google Cloud + uses: google-github-actions/auth@v2 + with: + token_format: access_token + workload_identity_provider: ${{secrets.GCR_WORKLOAD_IDENTITY_PROVIDER}} + service_account: ${{secrets.GCR_SERVICE_ACCOUNT}} + access_token_lifetime: 1800s + - name: Login to us Artifact Registry + uses: docker/login-action@v3 + with: + registry: us-docker.pkg.dev + username: oauth2accesstoken + password: ${{ steps.login-gcp.outputs.access_token }} + - name: Login to eu Artifact Registry + uses: docker/login-action@v3 + with: + registry: europe-docker.pkg.dev + username: oauth2accesstoken + password: ${{ steps.login-gcp.outputs.access_token }} + - name: Login to asia Artifact Registry + uses: docker/login-action@v3 + with: + registry: asia-docker.pkg.dev + username: oauth2accesstoken + password: ${{ steps.login-gcp.outputs.access_token }} + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{secrets.ECR_AWS_ACCESS_KEY_ID}} + aws-secret-access-key: ${{secrets.ECR_AWS_SECRET_ACCESS_KEY}} + aws-region: us-west-2 + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + - name: build and push + uses: docker/build-push-action@v5 + with: + push: true + context: . + file: ./cmd/otelcontribcol/Dockerfile + platforms: linux/amd64,linux/arm64 + tags: | + 609927696493.dkr.ecr.us-west-2.amazonaws.com/opentelemetry-collector-contrib:${{steps.create-version.outputs.BUILD_VERSION}} + ${{secrets.AAR_REPO_IMAGE}}:${{steps.create-version.outputs.BUILD_VERSION}} + ${{secrets.GCR_ASIA_IMAGE}}:${{steps.create-version.outputs.BUILD_VERSION}} + ${{secrets.GCR_EUROPE_IMAGE}}:${{steps.create-version.outputs.BUILD_VERSION}} + ${{secrets.GCR_US_IMAGE}}:${{steps.create-version.outputs.BUILD_VERSION}}