From 9810f4db1dfcfbde22448c178adb77294a2aa792 Mon Sep 17 00:00:00 2001 From: Cristovao Cordeiro Date: Fri, 17 Jan 2025 15:42:06 +0100 Subject: [PATCH] ci: add TiCS static code analysis --- .github/actions/build-chisel/action.yml | 30 ---------------------- .github/workflows/build.yml | 19 ++++++++++++-- .github/workflows/tests.yaml | 34 ++++--------------------- .github/workflows/tics.yml | 1 - 4 files changed, 22 insertions(+), 62 deletions(-) delete mode 100644 .github/actions/build-chisel/action.yml diff --git a/.github/actions/build-chisel/action.yml b/.github/actions/build-chisel/action.yml deleted file mode 100644 index c519bc2c..00000000 --- a/.github/actions/build-chisel/action.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: "Build chisel" -description: > - Generates the version file and builds chisel from the current project directory. - - The build can be configured via Go environment variables. -outputs: - CHISEL_VERSION: - description: "The chisel version" - value: ${{ steps.build.outputs.chisel-version }} -runs: - using: "composite" - steps: - - id: build - shell: bash - run: | - echo "Generating version file" - go generate ./cmd/ - - echo "Building for $GOOS $GOARCH" - go build -trimpath -ldflags='-s -w' ./cmd/chisel - - # Get version via "chisel version" to ensure it matches that exactly - CHISEL_VERSION=$(GOOS=linux GOARCH=amd64 go run ./cmd/chisel version) - echo "Version: $CHISEL_VERSION" - - # Version should not be "unknown" - [ "$CHISEL_VERSION" != "unknown" ] || exit 1 - - # Share variables with subsequent steps - echo "chisel-version=${CHISEL_VERSION}" >>$GITHUB_OUTPUT diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6bcdeb8f..d3d7ed64 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,13 +51,28 @@ jobs: with: go-version-file: 'go.mod' - - uses: ./.github/actions/build-chisel/ - name: Build Chisel for linux/${{ matrix.arch }} + - name: Build Chisel for linux/${{ matrix.arch }} id: build env: GOOS: "linux" GOARCH: ${{ matrix.arch }} CGO_ENABLED: "0" + run: | + echo "Generating version file" + go generate ./cmd/ + + echo "Building for $GOOS $GOARCH" + go build -trimpath -ldflags='-s -w' ./cmd/chisel + + # Get version via "chisel version" to ensure it matches that exactly + CHISEL_VERSION=$(GOOS=linux GOARCH=amd64 go run ./cmd/chisel version) + echo "Version: $CHISEL_VERSION" + + # Version should not be "unknown" + [ "$CHISEL_VERSION" != "unknown" ] || exit 1 + + # Share variables with subsequent steps + echo "CHISEL_VERSION=${CHISEL_VERSION}" >>$GITHUB_OUTPUT - name: Test if is executable run: test -x ./chisel diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d664557c..0f2e0425 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,23 +1,6 @@ name: Tests on: - workflow_call: - inputs: - repository: - description: 'Repository name (with owner) to clone' - required: true - type: string - ref: - description: 'The branch, tag or SHA to checkout' - required: true - type: string - outputs: - test-coverage-file: - description: 'The name of the coverage report file' - value: ${{ jobs.unit-tests.outputs.test-coverage-file }} - test-coverage-artifact: - description: 'The name used to upload the coverage file as a GH artifact' - value: ${{ jobs.unit-tests.outputs.test-coverage-artifact }} workflow_dispatch: push: paths-ignore: @@ -31,16 +14,9 @@ jobs: name: Unit Tests env: TEST_COVERAGE_FILE: test-coverage.out - TEST_COVERAGE_ARTIFACT: chisel-test-coverage TEST_COVERAGE_HTML_FILE: test-coverage.html - outputs: - test-coverage-file: ${{ env.TEST_COVERAGE_FILE }} - test-coverage-artifact: ${{ env.TEST_COVERAGE_ARTIFACT }} steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event_name == 'workflow_call' && inputs.ref || '' }} - repository: ${{ github.event_name == 'workflow_call' && inputs.repository || '' }} + - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: @@ -60,13 +36,13 @@ jobs: -o=${TEST_COVERAGE_HTML_FILE} fi - - name: Upload test coverage - uses: actions/upload-artifact@v4 + - name: Upload HTML test coverage + uses: actions/upload-artifact@v3 if: always() continue-on-error: true with: - name: ${{ env.TEST_COVERAGE_ARTIFACT }} - path: ./test-coverage* + name: chisel-test-coverage.html + path: ./*.html real-archive-tests: # Do not change to newer releases as "fips" may not be available there. diff --git a/.github/workflows/tics.yml b/.github/workflows/tics.yml index bed2a25a..db5926b1 100644 --- a/.github/workflows/tics.yml +++ b/.github/workflows/tics.yml @@ -92,7 +92,6 @@ jobs: codetype: 'TESTCODE' project: ${{ env.TICSPROJECT }} filelist: ${{ env.TICS_FILELIST }} - branchname: ${{ github.head_ref }} viewerUrl: 'https://canonical.tiobe.com/tiobeweb/TICS/api/cfg?name=default' displayUrl: 'https://canonical.tiobe.com/tiobeweb/TICS' ticsAuthToken: ${{ secrets.TICSAUTHTOKEN }}