Skip to content

Commit

Permalink
CI: Disable tics analysis on each merge and run it once per week
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Mars <paul.mars@canonical.com>
  • Loading branch information
upils committed Oct 10, 2024
1 parent 5578ca7 commit 60c4086
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 45 deletions.
92 changes: 47 additions & 45 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: Build and Tests

on:
push:
branches:
- main
pull_request:
on: [pull_request]

# on:
# push:
# branches:
# - main
# pull_request:

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
Expand Down Expand Up @@ -77,43 +79,43 @@ jobs:
shell: bash
run: ./tools/check-mkfs-confs.sh

tics-report:
runs-on: ubuntu-latest
needs: test
if: ${{ github.event_name == 'push' || github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: Download coverage report artifact
uses: actions/download-artifact@v4
with:
name: ubuntu-image-coverage-long
path: .coverage

- name: Install tools
run: |
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Convert report to xml
run: |
cd .coverage && \
gocov convert coverage-long.out > coverage.json && \
gocov-xml < coverage.json > coverage-go.xml
- name: TICS analysis and report
run: |
export TICSAUTHTOKEN=${{ secrets.TICSAUTHTOKEN }}
set -x
# Install the TICS and staticcheck
curl --silent --show-error "https://canonical.tiobe.com/tiobeweb/TICS/api/public/v1/fapi/installtics/Script?cfg=default&platform=linux&url=https://canonical.tiobe.com/tiobeweb/TICS/" > install_tics.sh
. ./install_tics.sh
TICSQServer -project ubuntu-image -tmpdir /tmp/tics -branchdir .
# tics-report:
# runs-on: ubuntu-latest
# needs: test
# if: ${{ github.event_name == 'push' || github.ref == 'refs/heads/main' }}
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 2

# - uses: actions/setup-go@v5
# with:
# go-version: '1.21'

# - name: Download coverage report artifact
# uses: actions/download-artifact@v4
# with:
# name: ubuntu-image-coverage-long
# path: .coverage

# - name: Install tools
# run: |
# go install github.com/axw/gocov/gocov@latest
# go install github.com/AlekSi/gocov-xml@latest
# go install honnef.co/go/tools/cmd/staticcheck@latest

# - name: Convert report to xml
# run: |
# cd .coverage && \
# gocov convert coverage-long.out > coverage.json && \
# gocov-xml < coverage.json > coverage-go.xml

# - name: TICS analysis and report
# run: |
# export TICSAUTHTOKEN=${{ secrets.TICSAUTHTOKEN }}

# set -x
# # Install the TICS and staticcheck
# curl --silent --show-error "https://canonical.tiobe.com/tiobeweb/TICS/api/public/v1/fapi/installtics/Script?cfg=default&platform=linux&url=https://canonical.tiobe.com/tiobeweb/TICS/" > install_tics.sh
# . ./install_tics.sh
# TICSQServer -project ubuntu-image -tmpdir /tmp/tics -branchdir .
79 changes: 79 additions & 0 deletions .github/workflows/tiobe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: "TIOBE/TiCS"

on:
schedule:
- cron: '0 0 * * TUE'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: build go binary
run: CGO_ENABLED=0 go build ./...

- name: apt-update
run: sudo apt update

- name: install-test-dependencies
run: sudo apt install -y snapd germinate e2fsprogs mtools debootstrap eatmydata fdisk gdisk qemu-system-aarch64 qemu-user-static ubuntu-dev-tools

- name: run tests
run: sudo go test -timeout 0 -v -coverprofile=.coverage/coverage-long.out -coverpkg $(go list ./... 2> /dev/null | tr '\n' ",") -covermode=atomic ./...

- name: Upload coverage report to artifacts
uses: actions/upload-artifact@v4
with:
name: ubuntu-image-coverage-long
path: .coverage/coverage-*.out
retention-days: 1
if-no-files-found: error
include-hidden-files: true

tics-report:
runs-on: ubuntu-latest
needs: test
if: ${{ github.repository == 'canonical/ubuntu-image' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: Download coverage report artifact
uses: actions/download-artifact@v4
with:
name: ubuntu-image-coverage-long
path: .coverage

- name: Install tools
run: |
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Convert report to xml
run: |
cd .coverage && \
gocov convert coverage-long.out > coverage.json && \
gocov-xml < coverage.json > coverage-go.xml
- name: TICS analysis and report
run: |
export TICSAUTHTOKEN=${{ secrets.TICSAUTHTOKEN }}
set -x
# Install the TICS and staticcheck
curl --silent --show-error "https://canonical.tiobe.com/tiobeweb/TICS/api/public/v1/fapi/installtics/Script?cfg=default&platform=linux&url=https://canonical.tiobe.com/tiobeweb/TICS/" > install_tics.sh
. ./install_tics.sh
TICSQServer -project ubuntu-image -tmpdir /tmp/tics -branchdir .

0 comments on commit 60c4086

Please sign in to comment.