From a753f84c3b8e4153935e58e1961396a5f276a982 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Fri, 27 Jan 2023 09:53:38 +0100 Subject: [PATCH 1/3] action: build and test on Linux GH runners --- .github/workflows/test-linux.yml | 123 +++++++++++++++++++++++ .github/workflows/test-reporter.yml | 20 ++++ Jenkinsfile | 146 +--------------------------- 3 files changed, 144 insertions(+), 145 deletions(-) create mode 100644 .github/workflows/test-linux.yml create mode 100644 .github/workflows/test-reporter.yml diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml new file mode 100644 index 000000000..639343b0e --- /dev/null +++ b/.github/workflows/test-linux.yml @@ -0,0 +1,123 @@ +name: test-linux + +on: + push: + branches: + - main + paths-ignore: + - '*.md' + - '*.asciidoc' + - 'docs/**' + pull_request: + paths-ignore: + - '*.md' + - '*.asciidoc' + - 'docs/**' + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: .ci/linux/build.sh + + - name: Package + run: .ci/linux/release.sh true + + - name: Rustup + run: rustup default 1.59.0 + + - name: Cargo make + run: cargo install --force cargo-make + + - name: Build profiler + run: ./build.sh profiler-zip + + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Test & coverage + run: .ci/linux/test.sh + + - name: Store test results + if: success() || failure() + uses: actions/upload-artifact@v3 + with: + name: test-results + path: test/**/junit-*.xml + + startup-hook-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Build agent-zip + run: ./build.sh agent-zip + + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 3.1.100 + 5.0.100 + 6.0.100 + 7.0.100 + - name: Startup Hook Tests + run: .ci/linux/test-startuphooks.sh + + - name: Store test results + if: success() || failure() + uses: actions/upload-artifact@v3 + with: + name: test-results + path: test/**/junit-*.xml + + profiler-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Rustup + run: rustup default 1.59.0 + + - name: Cargo make + run: cargo install --force cargo-make + + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 3.1.100 + 5.0.100 + 6.0.100 + 7.0.100 + - name: Build profiler + run: ./build.sh profiler-zip + + - name: Profiler Tests + run: .ci/linux/test-profiler.sh + + - name: Create Docker Image + run: .ci/linux/build_docker.sh + + - name: Store test results + if: success() || failure() + uses: actions/upload-artifact@v3 + with: + name: test-results + path: test/**/junit-*.xml diff --git a/.github/workflows/test-reporter.yml b/.github/workflows/test-reporter.yml new file mode 100644 index 000000000..86fb01048 --- /dev/null +++ b/.github/workflows/test-reporter.yml @@ -0,0 +1,20 @@ +--- +## Workflow to process the JUnit test results and add a report to the checks. +name: test-reporter +on: + workflow_run: + workflows: + - test-linux + types: + - completed + +jobs: + report: + runs-on: ubuntu-latest + steps: + - uses: elastic/apm-pipeline-library/.github/actions/test-report@current + with: + artifact: test-results # artifact name + name: JUnit Tests # Name of the check run which will be created + path: "test/**/junit-*.xml" # Path to test results (inside artifact .zip) + reporter: java-junit # Format of test results diff --git a/Jenkinsfile b/Jenkinsfile index c990be53a..42d3d1098 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -68,149 +68,6 @@ pipeline { } } parallel{ - stage('Linux'){ - options { skipDefaultCheckout() } - environment { - MSBUILDDEBUGPATH = "${env.WORKSPACE}" - } - /** - Make sure there are no code style violation in the repo. - */ - stages{ - // Disable until https://github.com/elastic/apm-agent-dotnet/issues/563 - // stage('CodeStyleCheck') { - // steps { - // withGithubNotify(context: 'CodeStyle check') { - // deleteDir() - // unstash 'source' - // dir("${BASE_DIR}"){ - // dotnet(){ - // sh label: 'Install and run dotnet/format', script: '.ci/linux/codestyle.sh' - // } - // } - // } - // } - // } - /** - Build the project from code.. - */ - stage('Build') { - steps { - withGithubNotify(context: 'Build - Linux') { - deleteDir() - unstash 'source' - dir("${BASE_DIR}"){ - dotnet(){ - sh '.ci/linux/build.sh' - // build nuget packages and profiler - sh(label: 'Package', script: '.ci/linux/release.sh true') - sh label: 'Rustup', script: 'rustup default 1.59.0' - sh label: 'Cargo make', script: 'cargo install --force cargo-make' - sh(label: 'Build profiler', script: './build.sh profiler-zip') - } - } - } - } - post { - unsuccessful { - archiveArtifacts(allowEmptyArchive: true, - artifacts: "${MSBUILDDEBUGPATH}/**/MSBuild_*.failure.txt") - } - success { - archiveArtifacts(allowEmptyArchive: true, artifacts: "${BASE_DIR}/build/output/_packages/*.nupkg,${BASE_DIR}/build/output/*.zip") - stash(allowEmpty: true, name: 'snapshoty-linux', includes: "${BASE_DIR}/.ci/snapshoty.yml,${BASE_DIR}/build/output/**", useDefaultExcludes: false) - } - } - } - /** - Execute unit tests. - */ - stage('Test') { - steps { - withGithubNotify(context: 'Test - Linux', tab: 'tests') { - deleteDir() - unstash 'source' - filebeat(output: "docker.log"){ - dir("${BASE_DIR}"){ - testTools(){ - dotnet(){ - sh label: 'Test & coverage', script: '.ci/linux/test.sh' - } - } - } - } - } - } - post { - always { - reportTests() - publishCoverage(adapters: [coberturaAdapter("${BASE_DIR}/target/**/*coverage.cobertura.xml")], - sourceFileResolver: sourceFiles('STORE_ALL_BUILD')) - codecov(repo: env.REPO, basedir: "${BASE_DIR}", secret: "${CODECOV_SECRET}") - } - unsuccessful { - archiveArtifacts(allowEmptyArchive: true, - artifacts: "${MSBUILDDEBUGPATH}/**/MSBuild_*.failure.txt") - } - } - } - stage('Startup Hook Tests') { - steps { - withGithubNotify(context: 'Test startup hooks - Linux', tab: 'tests') { - deleteDir() - unstash 'source' - dir("${BASE_DIR}"){ - dotnet(){ - sh label: 'Build', script: './build.sh agent-zip' - sh label: 'Test & coverage', script: '.ci/linux/test-startuphooks.sh' - } - } - } - } - post { - always { - reportTests() - } - unsuccessful { - archiveArtifacts(allowEmptyArchive: true, artifacts: "${MSBUILDDEBUGPATH}/**/MSBuild_*.failure.txt") - } - } - } - stage('Profiler Tests') { - steps { - withGithubNotify(context: 'Test profiler - Linux', tab: 'tests') { - deleteDir() - unstash 'source' - dir("${BASE_DIR}"){ - dotnet(){ - sh label: 'Rustup', script: 'rustup default 1.59.0' - sh label: 'Cargo make', script: 'cargo install --force cargo-make' - sh label: 'Build', script: './build.sh profiler-zip' - sh label: 'Test & coverage', script: '.ci/linux/test-profiler.sh' - } - } - } - } - post { - always { - reportTests() - } - unsuccessful { - archiveArtifacts(allowEmptyArchive: true, artifacts: "${MSBUILDDEBUGPATH}/**/MSBuild_*.failure.txt") - } - } - } - stage('Create Docker image') { - steps { - withGithubNotify(context: 'Create Docker image - Linux') { - dir("${BASE_DIR}"){ - sh(label: 'Create Docker Image', script: '.ci/linux/build_docker.sh') - } - } - } - } - } - } stage('Windows .NET Framework'){ agent { label 'windows-2019 && immutable' } options { skipDefaultCheckout() } @@ -497,7 +354,6 @@ pipeline { steps { withGithubNotify(context: 'Publish snapshot packages') { deleteDir() - unstash(name: 'snapshoty-linux') unstash(name: 'snapshoty-windows') dir(env.BASE_DIR) { snapshoty( @@ -678,7 +534,7 @@ def testTools(Closure body){ | jq -r '.[].assets[].browser_download_url' \ | grep 'Azure.Functions.Cli.linux-x64.4.*zip\$' \ | head -n 1) - + # Preserve only the filename component of the URL latest_v4_release_file=\${latest_v4_release_url##*/} From 4699347cb1b353137780ced371c5ff1f90f2bb30 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Mon, 22 May 2023 13:35:26 +0200 Subject: [PATCH 2/3] bump rustup --- .github/workflows/test-linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 639343b0e..8fd3339b3 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -35,7 +35,7 @@ jobs: run: .ci/linux/release.sh true - name: Rustup - run: rustup default 1.59.0 + run: rustup default 1.67.1 - name: Cargo make run: cargo install --force cargo-make @@ -93,7 +93,7 @@ jobs: - uses: actions/checkout@v3 - name: Rustup - run: rustup default 1.59.0 + run: rustup default 1.67.1 - name: Cargo make run: cargo install --force cargo-make From e0eee1230599a1388033b72900f75c7e0dd60f03 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Mon, 22 May 2023 13:43:15 +0200 Subject: [PATCH 3/3] ensure cargo make gets installed first --- .github/workflows/test-linux.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 8fd3339b3..07bfc078d 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -27,6 +27,12 @@ jobs: steps: - uses: actions/checkout@v3 + + - name: Rustup + run: rustup default 1.67.1 + + - name: Cargo make + run: cargo install --force cargo-make - name: Build run: .ci/linux/build.sh @@ -34,12 +40,6 @@ jobs: - name: Package run: .ci/linux/release.sh true - - name: Rustup - run: rustup default 1.67.1 - - - name: Cargo make - run: cargo install --force cargo-make - - name: Build profiler run: ./build.sh profiler-zip