diff --git a/.github/workflows/code-climate.yml b/.github/workflows/code-climate.yml new file mode 100644 index 0000000..0911731 --- /dev/null +++ b/.github/workflows/code-climate.yml @@ -0,0 +1,38 @@ +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 commit + uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} + + - 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 + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ba3e93b..d6e5195 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,32 +123,33 @@ 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 - - - 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 + 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: 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 +191,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: