From 3e1862d3e365541f80240d940301f706d58b0f9d Mon Sep 17 00:00:00 2001 From: Samuel Pelegrinello Caipers Date: Fri, 9 Feb 2024 16:23:28 +0000 Subject: [PATCH 1/5] Add first version for code-climate --- .github/workflows/code-climate.yml | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/code-climate.yml diff --git a/.github/workflows/code-climate.yml b/.github/workflows/code-climate.yml new file mode 100644 index 00000000..52cebc95 --- /dev/null +++ b/.github/workflows/code-climate.yml @@ -0,0 +1,36 @@ +name: Code Climate + +on: + workflow_run: + workflows: ["Test"] + # avoid running once merged on main branch, this should be run only on PRs + branches-ignore: ["main"] + # run this once one of the workflow is triggered. + types: + - requested + +jobs: + code-climate: + name: Set up + runs-on: ubuntu-22.04 + steps: + - name: Checkout PR head + uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} + + # - name: Download and Extract Artifacts + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # run: | + # mkdir -p artifacts && cd artifacts + # artifacts_url=${{ github.event.workflow_run.artifacts_url }} + # gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact + # do + # IFS=$'\t' read name url <<< "$artifact" + # if [[ $name == "Event File"* ]]; then + # name="Event File" + # fi + # gh api $url > "$name.zip" + # unzip -d "$name" "$name.zip" + # done From ed78f0f0d04e2a571ae98324e156a69f3b423e49 Mon Sep 17 00:00:00 2001 From: Samuel Pelegrinello Caipers Date: Fri, 9 Feb 2024 16:47:37 +0000 Subject: [PATCH 2/5] Install go, install code climate cli, run tests --- .github/workflows/code-climate.yml | 34 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/code-climate.yml b/.github/workflows/code-climate.yml index 52cebc95..0911731a 100644 --- a/.github/workflows/code-climate.yml +++ b/.github/workflows/code-climate.yml @@ -14,23 +14,25 @@ jobs: name: Set up runs-on: ubuntu-22.04 steps: - - name: Checkout PR head + - name: Checkout PR head commit uses: actions/checkout@v4 with: ref: ${{ github.event.workflow_run.head_sha }} - # - name: Download and Extract Artifacts - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # run: | - # mkdir -p artifacts && cd artifacts - # artifacts_url=${{ github.event.workflow_run.artifacts_url }} - # gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact - # do - # IFS=$'\t' read name url <<< "$artifact" - # if [[ $name == "Event File"* ]]; then - # name="Event File" - # fi - # gh api $url > "$name.zip" - # unzip -d "$name" "$name.zip" - # done + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + check-latest: true + + - name: Install code climate cli + run: | + curl -L https://github.com/codeclimate/codeclimate/archive/master.tar.gz | tar xvz + cd codeclimate-* && sudo make install + ls -la + + - name: Run unit tests + run: | + mkdir -p build + make test > build/cpackgettests-linux-amd64.txt + From 16688fb471b8f5624b70177bb11dadfdac99e251 Mon Sep 17 00:00:00 2001 From: Samuel Pelegrinello Caipers Date: Thu, 8 Feb 2024 10:30:14 +0000 Subject: [PATCH 3/5] DEBUGINFRA-861: Run tests on Arm-based Macs --- .github/workflows/test.yml | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e416c92..5132fe46 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: Test on: workflow_dispatch: - push: + push: branches: [main] pull_request: paths: @@ -85,20 +85,27 @@ jobs: run: | make test-xmllint-localrepository - test-amd64: + test-native: strategy: matrix: - # Tests on Mac are currently broken + # Runners + # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners goos: [windows, linux, darwin] include: - goos: windows runs-on: windows-latest + arch: amd64 - goos: linux runs-on: ubuntu-latest + arch: amd64 - goos: darwin runs-on: macos-latest + arch: amd64 + - goos: darwin + runs-on: macos-14 + arch: arm64 - name: "${{ matrix.goos }} | amd64" + name: "${{ matrix.goos }} | ${{ matrix.arch }} native" runs-on: ${{ matrix.runs-on }} steps: - name: Check out repository code @@ -116,13 +123,13 @@ jobs: - name: Run unit tests run: | mkdir -p build - make test > build/cpackgettests-${{ matrix.goos }}-amd64.txt + make test > build/cpackgettests-${{ matrix.goos }}-${{ matrix.arch }}.txt - name: Generate JUnit test report if: always() run: | - go-junit-report -set-exit-code -in build/cpackgettests-${{ matrix.goos }}-amd64.txt -iocopy -out build/cpackget-testreport-${{ matrix.goos }}-amd64.xml - + go-junit-report -set-exit-code -in build/cpackgettests-${{ matrix.goos }}-${{ matrix.arch }}.txt -iocopy -out build/cpackget-testreport-${{ matrix.goos }}-${{ matrix.arch }}.xml + - name: Publish coverage report to Code Climate if: ${{ startsWith(matrix.runs-on, 'ubuntu') && (github.workflow != 'Release') }} uses: paambaati/codeclimate-action@v5.0.0 @@ -136,12 +143,12 @@ jobs: - name: Archive unit test results uses: actions/upload-artifact@v4 with: - name: test-results-${{ matrix.goos }}-amd64 - path: ./build/cpackget-testreport-${{ matrix.goos }}-amd64.xml + name: test-results-${{ matrix.goos }}-${{ matrix.arch }} + path: ./build/cpackget-testreport-${{ matrix.goos }}-${{ matrix.arch }}.xml if-no-files-found: error - test-linux-arm64: - name: "linux | arm64" + test-linux-arm64-emulated: + name: "linux | arm64 emulated" runs-on: ubuntu-latest steps: - name: Unit testing @@ -183,7 +190,7 @@ jobs: - name: Generate JUnit test report run: | go-junit-report -set-exit-code -in ${PWD}/artifacts/cpackgettests-linux-arm64.txt -iocopy -out ./cpackget-testreport-linux-arm64.xml - + - name: Archive unit test results uses: actions/upload-artifact@v4 with: From 9ce4ae8ecc413fe28483cdcc1bea7a7429d4392b Mon Sep 17 00:00:00 2001 From: Samuel Pelegrinello Caipers Date: Mon, 12 Feb 2024 10:10:35 +0000 Subject: [PATCH 4/5] Removing codeclimate from test --- .github/workflows/test.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5132fe46..66c2557b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -130,15 +130,15 @@ jobs: run: | go-junit-report -set-exit-code -in build/cpackgettests-${{ matrix.goos }}-${{ matrix.arch }}.txt -iocopy -out build/cpackget-testreport-${{ matrix.goos }}-${{ matrix.arch }}.xml - - name: Publish coverage report to Code Climate - if: ${{ startsWith(matrix.runs-on, 'ubuntu') && (github.workflow != 'Release') }} - uses: paambaati/codeclimate-action@v5.0.0 - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - with: - debug: true - coverageLocations: ./cover.out:gocov - prefix: github.com/open-cmsis-pack/cpackget + # - name: Publish coverage report to Code Climate + # if: ${{ startsWith(matrix.runs-on, 'ubuntu') && (github.workflow != 'Release') }} + # uses: paambaati/codeclimate-action@v5.0.0 + # env: + # CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + # with: + # debug: true + # coverageLocations: ./cover.out:gocov + # prefix: github.com/open-cmsis-pack/cpackget - name: Archive unit test results uses: actions/upload-artifact@v4 From 5d862fee1b1befbb3aa2495c46eed5ad65afcbab Mon Sep 17 00:00:00 2001 From: Samuel Pelegrinello Caipers Date: Mon, 12 Feb 2024 10:16:16 +0000 Subject: [PATCH 5/5] Removing codeclimate from test 2 --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 66c2557b..72378a64 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -140,6 +140,7 @@ jobs: # coverageLocations: ./cover.out:gocov # prefix: github.com/open-cmsis-pack/cpackget + - name: Archive unit test results uses: actions/upload-artifact@v4 with: