Skip to content

Commit

Permalink
Github: Tiobe TICS integration (#14082)
Browse files Browse the repository at this point in the history
And some other small tweaks.

Later on we should look at de-duping some of the repeated steps, such as
space reclaim, into sub-workflows we can call from multiple places.

Example of a successful test run on my fork:
https://github.com/tomponline/lxd/actions/runs/10817095654

Once merged will need to GH TICS secrete set up.
  • Loading branch information
tomponline authored Sep 12, 2024
2 parents b0a67ab + 4d81f6e commit fd2b1cf
Showing 1 changed file with 154 additions and 4 deletions.
158 changes: 154 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ jobs:
name: Code
runs-on: ubuntu-22.04
steps:
- name: Performance tuning
run: |
set -eux
# optimize ext4 FSes for performance, not reliability
for fs in $(findmnt --noheading --type ext4 --list --uniq | awk '{print $1}'); do
# nombcache and data=writeback cannot be changed on remount
sudo mount -o remount,noatime,barrier=0,commit=6000 "${fs}" || true
done
# disable dpkg from calling sync()
echo "force-unsafe-io" | sudo tee /etc/dpkg/dpkg.cfg.d/force-unsafe-io
- name: Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -74,6 +86,8 @@ jobs:
sudo add-apt-repository ppa:ubuntu-lxc/daily -y --no-update
sudo apt-get update
sudo systemctl mask lxc.service lxc-net.service
sudo apt-get install --no-install-recommends -y \
build-essential \
curl \
Expand All @@ -94,6 +108,9 @@ jobs:
pkg-config \
shellcheck
# reclaim some space
sudo apt-get clean
python3 -m pip install flake8
# Download minio ready to include in dependencies for system tests.
Expand Down Expand Up @@ -271,12 +288,16 @@ jobs:
# This was inspired from https://github.com/easimon/maximize-build-space
df -h /
# dotnet
sudo rm -rf /usr/share/dotnet
# android
sudo rm -rf /usr/local/lib/android
# haskell
sudo rm -rf /opt/ghc
# codeql
sudo rm -rf /opt/hostedtoolcache/CodeQL
df -h /
- name: Remove docker
Expand Down Expand Up @@ -354,6 +375,7 @@ jobs:

- name: Set exec perms on LXD binaries
run: |
set -eux
ls -lR /home/runner/go/bin/
chmod uog+x /home/runner/go/bin/*
Expand Down Expand Up @@ -421,8 +443,13 @@ jobs:
sudo microceph.ceph status
sudo rm -f /snap/bin/rbd
# reclaim some space
sudo apt-get clean
- name: Make GOCOVERDIR
run: mkdir -p "${GOCOVERDIR}"
run: |
set -eux
mkdir -p "${GOCOVERDIR}"
if: env.GOCOVERDIR != ''

- name: "Run system tests (${{ matrix.go }}, ${{ matrix.suite }}, ${{ matrix.backend }})"
Expand All @@ -440,6 +467,120 @@ jobs:
path: ${{env.GOCOVERDIR}}
if: env.GOCOVERDIR != ''

tics:
name: Tiobe TICS
runs-on: ubuntu-22.04
needs: system-tests
env:
CGO_CFLAGS: "-I/home/runner/go/bin/dqlite/include/"
CGO_LDFLAGS: "-L/home/runner/go/bin/dqlite/libs/"
LD_LIBRARY_PATH: "/home/runner/go/bin/dqlite/libs/"
CGO_LDFLAGS_ALLOW: "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
TICSAUTHTOKEN: ${{ secrets.TICS_AUTH_TOKEN }}
if: ${{ github.event_name == 'workflow_dispatch' }}
steps:
- name: Performance tuning
run: |
set -eux
# optimize ext4 FSes for performance, not reliability
for fs in $(findmnt --noheading --type ext4 --list --uniq | awk '{print $1}'); do
# nombcache and data=writeback cannot be changed on remount
sudo mount -o remount,noatime,barrier=0,commit=6000 "${fs}" || true
done
# disable dpkg from calling sync()
echo "force-unsafe-io" | sudo tee /etc/dpkg/dpkg.cfg.d/force-unsafe-io
- name: Reclaim some space
run: |
set -eux
# Purge snaps and snapd.
sudo snap remove --purge $(snap list | awk '!/^Name|^core|^snapd/ {print $1}') && sudo apt-get autopurge -y snapd
# This was inspired from https://github.com/easimon/maximize-build-space
df -h /
# dotnet
sudo rm -rf /usr/share/dotnet
# android
sudo rm -rf /usr/local/lib/android
# haskell
sudo rm -rf /opt/ghc
# codeql
sudo rm -rf /opt/hostedtoolcache/CodeQL
df -h /
- name: Remove docker
run: |
set -eux
sudo apt-get autopurge -y containerd.io moby-containerd docker docker-ce podman uidmap
sudo ip link delete docker0
sudo nft flush ruleset
- name: Checkout
uses: actions/checkout@v4
with:
# A non-shallow clone is needed for the Differential ShellCheck
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x

- name: Download coverage data
uses: actions/download-artifact@v4
with:
pattern: coverage-*
path: ${{env.GOCOVERDIR}}
merge-multiple: true

- name: Download system test dependencies
uses: actions/download-artifact@v4
with:
name: system-test-deps
merge-multiple: true
path: /home/runner/go/bin

- name: Install dependencies
run: |
set -eux
sudo add-apt-repository ppa:ubuntu-lxc/daily -y --no-update
sudo apt-get update
sudo systemctl mask lxc.service lxc-net.service
sudo apt-get install --no-install-recommends -y \
libcap-dev \
libacl1-dev \
libuv1-dev \
libudev-dev \
liblxc-dev \
pkg-config \
libdbus-1-dev \
libseccomp-dev
# reclaim some space
sudo apt-get clean
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 coverage files
run: |
go tool covdata textfmt -i="${GOCOVERDIR}" -o "${GOCOVERDIR}"/coverage.out
gocov convert "${GOCOVERDIR}"/coverage.out > "${GOCOVERDIR}"/coverage.json
gocov-xml < "${GOCOVERDIR}"/coverage.json > "${GOCOVERDIR}"/coverage-go.xml
- name: Run TICS
run: |
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 LXD -tmpdir /tmp/tics -branchdir .
client:
name: Client
strategy:
Expand All @@ -464,20 +605,23 @@ jobs:

- name: Create build directory
run: |
set -eux
mkdir bin
- name: Build static lxc (x86_64)
env:
CGO_ENABLED: 0
GOARCH: amd64
run: |
set -eux
go build -ldflags "-s -w" -o trimpath -o bin/lxc.x86_64 ./lxc
- name: Build static lxc (aarch64)
env:
CGO_ENABLED: 0
GOARCH: arm64
run: |
set -eux
go build -ldflags "-s -w" -o trimpath -o bin/lxc.aarch64 ./lxc
- name: Build static lxd-benchmark
Expand All @@ -501,17 +645,23 @@ jobs:
- name: Unit tests (client)
env:
CGO_ENABLED: 0
run: go test -v ./client/...
run: |
set -eux
go test -v ./client/...
- name: Unit tests (lxc)
env:
CGO_ENABLED: 0
run: go test -v ./lxc/...
run: |
set -eux
go test -v ./lxc/...
- name: Unit tests (shared)
env:
CGO_ENABLED: 0
run: go test -v ./shared/...
run: |
set -eux
go test -v ./shared/...
- name: Upload lxc client artifacts
uses: actions/upload-artifact@v4
Expand Down

0 comments on commit fd2b1cf

Please sign in to comment.