Skip to content

Commit

Permalink
Run tests in all configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
soumeh01 committed Jul 31, 2023
1 parent 16214e9 commit 5433d0e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 42 deletions.
59 changes: 20 additions & 39 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
name: 'Test (${{ matrix.platform }})'
include:
- platform: ubuntu-latest
target: linux
- platform: windows-latest
target: windows
- platform: macos-latest
target: darwin
arch: [amd64, arm64]
name: 'Test (${{ matrix.target }}, ${{ matrix.arch }})'
runs-on: ${{ matrix.platform }}
steps:
- name: Check out repository code
Expand All @@ -78,41 +86,31 @@ jobs:
- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest

- name: Unit testing
run: |
mkdir -p build
go test -v ./... > build/cbuildtests-${{ matrix.platform }}-amd64.txt
- name: Generate unit test report
if: success() || failure()
run: |
go-junit-report -set-exit-code -in build/cbuildtests-${{ matrix.platform }}-amd64.txt -iocopy -out build/cbuildtests-${{ matrix.platform }}-amd64.xml
- name: Install qemu (for Linux-Arm64)
if: ${{ always() && startsWith(runner.os, 'Linux') }}
if: ${{ startsWith(runner.os, 'Linux') && matrix.arch == 'arm64' }}
run: |
sudo apt update
sudo apt-get install -y \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
qemu-user-binfmt
- name: Unit testing (for Linux-Arm64)
if: ${{ always() && startsWith(runner.os, 'Linux') }}
- name: Unit testing
run: |
GOOS=linux GOARCH=arm64 go test -v ./... > build/cbuildtests-${{ matrix.platform }}-arm64.txt
mkdir -p build
set GOOS=${{ matrix.target }} && set GOARCH=${{ matrix.arch }} && go test -v ./... > build/cbuildtests-${{ matrix.target }}-${{ matrix.arch }}.txt
- name: Generate unit test report (for Linux-Arm64)
- name: Generate unit test report
if: success() || failure()
run: |
go-junit-report -set-exit-code -in build/cbuildtests-${{ matrix.platform }}-arm64.txt -iocopy -out build/cbuildtests-${{ matrix.platform }}-arm64.xml
go-junit-report -set-exit-code -in build/cbuildtests-${{ matrix.target }}-${{ matrix.arch }}.txt -iocopy -out build/cbuild-testreport-${{ matrix.target }}-${{ matrix.arch }}.xml
- name: Archive unit test results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: unit-test-result-${{ matrix.platform }}
path: ./build/cbuildtests-*.xml
name: unit-test-result-${{ matrix.target }}-${{ matrix.arch }}
path: ./build/cbuild-testreport-*.xml
if-no-files-found: error

publish-test-results:
Expand All @@ -124,33 +122,16 @@ jobs:
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Download unit test report windows
uses: actions/download-artifact@v3
with:
name: unit-test-result-windows-latest
path: testreports/

- name: Download unit test report linux
uses: actions/download-artifact@v3
with:
name: unit-test-result-ubuntu-latest
path: testreports/

- name: Download unit test report macos
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: unit-test-result-macos-latest
path: testreports/
path: artifacts

- name: publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "testreports/*.xml"
files: "artifacts/**/cbuild-testreport-*.xml"
report_individual_runs: true
# with:
# commit: ${{ github.event.workflow_run.head_sha }}
# report_individual_runs: true
# junit_files: "testreports/*.xml"

coverage:
if: github.event_name != 'release'
Expand Down
3 changes: 1 addition & 2 deletions pkg/builder/cproject/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ func (r RunnerMock) ExecuteCommand(program string, quiet bool, args ...string) (
func init() {
// Prepare test data
_ = os.RemoveAll(testRoot + "/run")
time.Sleep(2 * time.Second)
time.Sleep(3 * time.Second)
_ = cp.Copy(testRoot+"/data", testRoot+"/run")

_ = os.MkdirAll(testRoot+"/run/bin", 0755)
_ = os.MkdirAll(testRoot+"/run/etc", 0755)

Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/configs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestGetInstallConfigs(t *testing.T) {
assert := assert.New(t)
t.Run("test get install configs with CMSIS_BUILD_ROOT", func(t *testing.T) {
err := os.Setenv("CMSIS_BUILD_ROOT", testRoot+"/run/bin")
assert.Error(err)
assert.Nil(err)
configs, err := GetInstallConfigs()
assert.Nil(err)
assert.NotEmpty(configs.BinPath)
Expand Down

0 comments on commit 5433d0e

Please sign in to comment.