2018-04-18 22:04:23 -07:00
|
|
|
---
|
|
|
|
image: ubuntu:latest
|
|
|
|
|
|
|
|
# XXX - add a deploy stage to publish man pages, docs, and coverage
|
|
|
|
# reports
|
|
|
|
|
2024-10-02 17:31:25 -03:00
|
|
|
workflow:
|
|
|
|
rules:
|
|
|
|
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
|
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
- if: $CI_COMMIT_BRANCH
|
|
|
|
|
2018-04-18 22:04:23 -07:00
|
|
|
stages:
|
|
|
|
- build
|
|
|
|
- test
|
2025-01-30 08:10:22 +01:00
|
|
|
- spread
|
2018-04-18 22:04:23 -07:00
|
|
|
|
2025-01-21 15:39:41 +01:00
|
|
|
.ubuntu-common:
|
2022-02-13 12:26:19 +00:00
|
|
|
before_script:
|
2025-01-21 15:39:41 +01:00
|
|
|
# Install build-dependencies by loading the package list from the ubuntu/debian cloud-init profile.
|
2025-01-21 17:46:04 +01:00
|
|
|
- printf '\e[0K%s:%s:%s[collapsed=true]\r\e[0K%s\n' section_start "$(date +%s)" install_deps "Installing dependencies..."
|
2022-02-13 12:26:19 +00:00
|
|
|
- apt-get update -qq
|
2025-01-21 15:39:41 +01:00
|
|
|
- apt-get install --yes yq make lsb-release
|
|
|
|
- |
|
|
|
|
printf 'include .image-garden.mk\n$(info $(UBUNTU_CLOUD_INIT_USER_DATA_TEMPLATE))\n.PHONY: nothing\nnothing:\n' \
|
|
|
|
| make -f - nothing \
|
|
|
|
| yq '.packages | .[]' \
|
|
|
|
| xargs apt-get install --yes --no-install-recommends
|
2025-01-21 17:46:04 +01:00
|
|
|
- printf '\e[0K%s:%s:%s\r\e[0K\n' section_end "$(date +%s)" install_deps
|
2025-01-21 15:39:41 +01:00
|
|
|
after_script:
|
|
|
|
# Inspect the kernel and lsb-release.
|
2022-02-13 12:26:19 +00:00
|
|
|
- lsb_release -a
|
|
|
|
- uname -a
|
|
|
|
|
2018-04-18 22:04:23 -07:00
|
|
|
build-all:
|
|
|
|
stage: build
|
2022-02-13 12:26:19 +00:00
|
|
|
extends:
|
2025-01-21 15:39:41 +01:00
|
|
|
- .ubuntu-common
|
|
|
|
script:
|
|
|
|
# Run the spread prepare section to build everything.
|
|
|
|
- yq -r '.prepare' <spread.yaml | SPREAD_PATH=. bash -xeu
|
2018-04-18 22:04:23 -07:00
|
|
|
artifacts:
|
|
|
|
name: ${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
|
|
|
|
expire_in: 30 days
|
|
|
|
untracked: true
|
|
|
|
paths:
|
2022-02-13 11:14:20 +00:00
|
|
|
- libraries/libapparmor/
|
|
|
|
- parser/
|
|
|
|
- binutils/
|
|
|
|
- utils/
|
|
|
|
- changehat/mod_apparmor/
|
|
|
|
- changehat/pam_apparmor/
|
|
|
|
- profiles/
|
2018-04-18 22:04:23 -07:00
|
|
|
|
2022-02-13 09:02:58 +00:00
|
|
|
test-libapparmor:
|
2018-04-18 22:04:23 -07:00
|
|
|
stage: test
|
2022-02-13 07:49:52 +00:00
|
|
|
needs: ["build-all"]
|
2022-02-13 12:26:19 +00:00
|
|
|
extends:
|
2025-01-21 15:39:41 +01:00
|
|
|
- .ubuntu-common
|
2018-04-18 22:04:23 -07:00
|
|
|
script:
|
2024-10-18 11:46:46 -07:00
|
|
|
# This is to touch the built files in the test stage to avoid needless rebuilding
|
|
|
|
- make -C libraries/libapparmor --touch
|
2022-02-13 11:14:20 +00:00
|
|
|
- make -C libraries/libapparmor check
|
2022-02-13 09:02:58 +00:00
|
|
|
|
|
|
|
test-parser:
|
|
|
|
stage: test
|
|
|
|
needs: ["build-all"]
|
2022-02-13 12:26:19 +00:00
|
|
|
extends:
|
2025-01-21 15:39:41 +01:00
|
|
|
- .ubuntu-common
|
2022-02-13 09:02:58 +00:00
|
|
|
script:
|
2024-10-18 11:46:46 -07:00
|
|
|
# This is to touch the built files in the test stage to avoid needless rebuilding
|
|
|
|
- make -C parser --touch
|
2024-10-18 11:34:36 -07:00
|
|
|
- make -C parser -j $(nproc) tst_binaries
|
2022-02-13 11:14:20 +00:00
|
|
|
- make -C parser check
|
2022-02-13 09:02:58 +00:00
|
|
|
|
|
|
|
test-binutils:
|
|
|
|
stage: test
|
|
|
|
needs: ["build-all"]
|
2022-02-13 12:26:19 +00:00
|
|
|
extends:
|
2025-01-21 15:39:41 +01:00
|
|
|
- .ubuntu-common
|
2022-02-13 09:02:58 +00:00
|
|
|
script:
|
2022-02-13 11:14:20 +00:00
|
|
|
- make -C binutils check
|
2022-02-13 09:02:58 +00:00
|
|
|
|
|
|
|
test-utils:
|
|
|
|
stage: test
|
|
|
|
needs: ["build-all"]
|
2022-02-13 12:26:19 +00:00
|
|
|
extends:
|
2025-01-21 15:39:41 +01:00
|
|
|
- .ubuntu-common
|
2022-02-13 09:02:58 +00:00
|
|
|
script:
|
2024-10-18 11:46:46 -07:00
|
|
|
# This is to touch the built files in the test stage to avoid needless rebuilding
|
|
|
|
- make -C utils --touch
|
|
|
|
|
2025-01-21 15:39:41 +01:00
|
|
|
# TODO: move those to cloud-init list?
|
2025-01-21 17:46:04 +01:00
|
|
|
- printf '\e[0K%s:%s:%s[collapsed=true]\r\e[0K%s\n' section_start "$(date +%s)" install_extra_deps "Installing additional dependencies..."
|
2024-08-13 16:58:25 +00:00
|
|
|
- apt-get install --no-install-recommends -y libc6-dev libjs-jquery libjs-jquery-throttle-debounce libjs-jquery-isonscreen libjs-jquery-tablesorter flake8 python3-coverage python3-notify2 python3-psutil python3-setuptools python3-tk python3-ttkthemes python3-gi
|
2025-01-21 17:46:04 +01:00
|
|
|
- printf '\e[0K%s:%s:%s\r\e[0K\n' section_end "$(date +%s)" install_extra_deps
|
2024-08-13 16:58:25 +00:00
|
|
|
|
2022-02-13 15:39:11 +00:00
|
|
|
# See apparmor/apparmor#221
|
|
|
|
- make -C parser/tst gen_dbus
|
|
|
|
- make -C parser/tst gen_xtrans
|
2022-02-13 11:14:20 +00:00
|
|
|
- make -C utils check
|
|
|
|
- make -C utils/test coverage-regression
|
2021-07-13 12:21:52 +02:00
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- utils/test/htmlcov/
|
2021-08-15 16:28:35 +02:00
|
|
|
when: always
|
2018-04-18 22:04:23 -07:00
|
|
|
|
2022-02-13 09:02:58 +00:00
|
|
|
test-mod-apparmor:
|
|
|
|
stage: test
|
|
|
|
needs: ["build-all"]
|
2022-02-13 12:26:19 +00:00
|
|
|
extends:
|
2025-01-21 15:39:41 +01:00
|
|
|
- .ubuntu-common
|
2022-02-13 09:02:58 +00:00
|
|
|
script:
|
2024-10-18 11:46:46 -07:00
|
|
|
# This is to touch the built files in the test stage to avoid needless rebuilding
|
|
|
|
- make -C changehat/mod_apparmor --touch
|
2022-02-13 11:14:20 +00:00
|
|
|
- make -C changehat/mod_apparmor check
|
2022-02-13 09:02:58 +00:00
|
|
|
|
|
|
|
test-profiles:
|
|
|
|
stage: test
|
|
|
|
needs: ["build-all"]
|
2022-02-13 12:26:19 +00:00
|
|
|
extends:
|
2025-01-21 15:39:41 +01:00
|
|
|
- .ubuntu-common
|
2022-02-13 09:02:58 +00:00
|
|
|
script:
|
2024-10-18 11:46:46 -07:00
|
|
|
# This is to touch the built files in the test stage to avoid needless rebuilding
|
|
|
|
- make -C profiles --touch
|
2022-02-13 11:14:20 +00:00
|
|
|
- make -C profiles check-parser
|
|
|
|
- make -C profiles check-abstractions.d
|
2024-04-12 21:25:43 -04:00
|
|
|
- make -C profiles check-local
|
2022-02-13 09:02:58 +00:00
|
|
|
|
2022-02-13 07:49:52 +00:00
|
|
|
shellcheck:
|
|
|
|
stage: test
|
|
|
|
needs: []
|
2022-02-13 12:26:19 +00:00
|
|
|
extends:
|
2025-01-21 15:39:41 +01:00
|
|
|
- .ubuntu-common
|
2022-02-13 07:49:52 +00:00
|
|
|
script:
|
2025-01-21 17:46:04 +01:00
|
|
|
- printf '\e[0K%s:%s:%s[collapsed=true]\r\e[0K%s\n' section_start "$(date +%s)" install_extra_deps "Installing additional dependencies..."
|
2024-04-30 16:46:32 -03:00
|
|
|
- apt-get install --no-install-recommends -y python3-minimal file shellcheck xmlstarlet
|
2025-01-21 17:46:04 +01:00
|
|
|
- printf '\e[0K%s:%s:%s\r\e[0K\n' section_end "$(date +%s)" install_extra_deps
|
2022-02-13 07:49:52 +00:00
|
|
|
- shellcheck --version
|
2022-02-13 08:47:30 +00:00
|
|
|
- './tests/bin/shellcheck-tree --format=checkstyle
|
2022-02-13 07:49:52 +00:00
|
|
|
| xmlstarlet tr tests/checkstyle2junit.xslt
|
|
|
|
> shellcheck.xml'
|
|
|
|
artifacts:
|
|
|
|
when: always
|
|
|
|
reports:
|
|
|
|
junit: shellcheck.xml
|
|
|
|
|
2018-04-18 22:04:23 -07:00
|
|
|
# Disabled due to aa-logprof dependency on /sbin/apparmor_parser existing
|
2022-02-13 11:14:20 +00:00
|
|
|
# - make -C profiles check-profiles
|
2018-04-18 22:04:23 -07:00
|
|
|
|
|
|
|
# test-pam_apparmor:
|
|
|
|
# - stage: test
|
|
|
|
# - script:
|
|
|
|
# - cd changehat/pam_apparmor && make check
|
2020-07-21 16:39:53 +00:00
|
|
|
|
|
|
|
include:
|
|
|
|
- template: SAST.gitlab-ci.yml
|
2022-02-21 11:31:44 -08:00
|
|
|
- template: Secret-Detection.gitlab-ci.yml
|
2022-02-13 12:49:21 +00:00
|
|
|
|
|
|
|
variables:
|
2022-02-13 13:20:07 +00:00
|
|
|
SAST_EXCLUDED_ANALYZERS: "eslint,flawfinder,semgrep,spotbugs"
|
2022-02-13 13:28:38 +00:00
|
|
|
SAST_BANDIT_EXCLUDED_PATHS: "*/tst/*, */test/*"
|
2023-03-27 10:05:40 -03:00
|
|
|
|
|
|
|
coverity:
|
|
|
|
stage: .post
|
|
|
|
extends:
|
2025-01-21 15:39:41 +01:00
|
|
|
- .ubuntu-common
|
2023-03-27 10:05:40 -03:00
|
|
|
script:
|
2025-01-21 17:46:04 +01:00
|
|
|
- printf '\e[0K%s:%s:%s[collapsed=true]\r\e[0K%s\n' section_start "$(date +%s)" install_extra_deps "Installing additional dependencies..."
|
2023-03-27 10:05:40 -03:00
|
|
|
- apt-get install --no-install-recommends -y curl git texlive-latex-recommended
|
2025-01-21 17:46:04 +01:00
|
|
|
- printf '\e[0K%s:%s:%s\r\e[0K\n' section_end "$(date +%s)" install_extra_deps
|
2023-03-27 10:05:40 -03:00
|
|
|
- curl -o /tmp/cov-analysis-linux64.tgz https://scan.coverity.com/download/linux64
|
|
|
|
--form project=$COVERITY_SCAN_PROJECT_NAME --form token=$COVERITY_SCAN_TOKEN
|
|
|
|
- tar xfz /tmp/cov-analysis-linux64.tgz
|
|
|
|
- COV_VERSION=$(ls -dt cov-analysis-linux64-* | head -1)
|
|
|
|
- PATH=$PATH:$(pwd)/$COV_VERSION/bin
|
|
|
|
- make coverity
|
2025-01-20 14:06:49 +01:00
|
|
|
- curl https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME
|
|
|
|
--form token=$COVERITY_SCAN_TOKEN --form email=$GITLAB_USER_EMAIL
|
|
|
|
--form file=@$(ls apparmor-*-cov-int.tar.gz) --form version="$(git describe --tags)"
|
|
|
|
--form description="$(git describe --tags) / $CI_COMMIT_TITLE / $CI_COMMIT_REF_NAME:$CI_PIPELINE_ID"
|
2023-03-27 10:05:40 -03:00
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- "apparmor-*.tar.gz"
|
2025-01-20 14:05:52 +01:00
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PROJECT_PATH == "apparmor/apparmor"
|
2025-01-30 08:10:22 +01:00
|
|
|
|
|
|
|
.spread:
|
|
|
|
stage: spread
|
|
|
|
# TODO: use tagged release once container tagging is improved upstream.
|
|
|
|
image: registry.gitlab.com/zygoon/image-garden:latest
|
|
|
|
variables:
|
|
|
|
ARCH: x86_64 # for cache key :/
|
|
|
|
GARDEN_DL_DIR: dl
|
|
|
|
# GitLab project identifier of zygoon/spread-dist can be seen on
|
|
|
|
# https://gitlab.com/zygoon/spread-dist, under the three-dot menu on
|
|
|
|
# top-right.
|
|
|
|
SPREAD_GITLAB_PROJECT_ID: "65375371"
|
|
|
|
# Git revision of spread to install.
|
|
|
|
# This must have been built via spread-dist.
|
|
|
|
# TODO: switch to upstream 1.0 release when available.
|
|
|
|
SPREAD_REV: 413817eda7bec07a3885e0717c178b965f8924e1
|
|
|
|
# Run all the tasks for a given system.
|
|
|
|
SPREAD_ARGS: "garden:$GARDEN_SYSTEM:"
|
|
|
|
before_script:
|
|
|
|
# Prepare the image in dry-run mode. This helps in debugging cache misses
|
|
|
|
# when files are not cached correctly by the runner, causing the build section
|
|
|
|
# below to always do hevy-duty work.
|
|
|
|
- printf '\e[0K%s:%s:%s[collapsed=true]\r\e[0K%s\n' section_start "$(date +%s)" prepare_image_dry_run "Prepare image (dry run)"
|
|
|
|
- image-garden make --dry-run --debug "$GARDEN_SYSTEM.$ARCH.run"
|
|
|
|
- printf '\e[0K%s:%s:%s\r\e[0K\n' section_end "$(date +%s)" prepare_image_dry_run
|
|
|
|
|
|
|
|
# Prepare the image, for real.
|
|
|
|
- printf '\e[0K%s:%s:%s[collapsed=true]\r\e[0K%s\n' section_start "$(date +%s)" prepare_image "Prepare image"
|
|
|
|
- image-garden make "$GARDEN_SYSTEM.$ARCH.run"
|
|
|
|
- printf '\e[0K%s:%s:%s\r\e[0K\n' section_end "$(date +%s)" prepare_image
|
|
|
|
|
|
|
|
# Install the selected revision of spread.
|
|
|
|
- printf '\e[0K%s:%s:%s[collapsed=true]\r\e[0K%s\n' section_start "$(date +%s)" install_spread "Installing spread..."
|
|
|
|
# Install pre-built spread from https://gitlab.com/zygoon/spread-dist generic package repository.
|
|
|
|
- |
|
|
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --location --output spread "${CI_API_V4_URL}/projects/${SPREAD_GITLAB_PROJECT_ID}/packages/generic/spread/${SPREAD_REV}/spread.${SPREAD_GOARCH}"
|
|
|
|
- chmod +x spread
|
|
|
|
- printf '\e[0K%s:%s:%s\r\e[0K\n' section_end "$(date +%s)" install_spread
|
|
|
|
script:
|
|
|
|
- printf '\e[0K%s:%s:%s\r\e[0K%s\n' section_start "$(date +%s)" run_spread "Running spread for $GARDEN_SYSTEM..."
|
|
|
|
# TODO: transform to inject ^...$ to properly select jobs to run.
|
|
|
|
- mkdir -p spread-logs spread-artifacts
|
|
|
|
- ./spread -list $SPREAD_ARGS |
|
|
|
|
split --number=l/${CI_NODE_INDEX:-1}/"${CI_NODE_TOTAL:-1}" |
|
|
|
|
xargs --verbose ./spread -v -artifacts ./spread-artifacts -v | tee spread-logs/"$GARDEN_SYSTEM".log
|
|
|
|
- printf '\e[0K%s:%s:%s\r\e[0K\n' section_end "$(date +%s)" run_spread
|
|
|
|
cache:
|
|
|
|
# Cache the base image (pre-customization).
|
|
|
|
- key: image-garden-base-${GARDEN_SYSTEM}.${ARCH}
|
|
|
|
policy: $POLICY
|
|
|
|
when: always
|
|
|
|
paths:
|
|
|
|
- $GARDEN_DL_DIR
|
|
|
|
# Those are never mutated so they are safe to share.
|
|
|
|
- efi-code.*.img
|
|
|
|
- efi-vars.*.img
|
|
|
|
# Cache the customized system. This cache depends on .image-garden.mk file
|
|
|
|
# so that any customization updates are immediately acted upon.
|
|
|
|
- key:
|
|
|
|
prefix: image-garden-custom-${GARDEN_SYSTEM}.${ARCH}-
|
|
|
|
files:
|
|
|
|
- .image-garden.mk
|
|
|
|
policy: $POLICY
|
|
|
|
when: always
|
|
|
|
paths:
|
|
|
|
- $GARDEN_SYSTEM.*
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- spread-logs
|
|
|
|
- spread-artifacts
|
|
|
|
when: always
|
|
|
|
rules:
|
2025-01-30 14:40:30 +01:00
|
|
|
# Due to default cache protection logic in GitLab, pipelines running in
|
|
|
|
# protected branches (like master in the AppArmor project) do not get
|
|
|
|
# access, even read access, to protected cache. As such we need to allow
|
|
|
|
# non-protected branches to push the cache sometimes, or we'd pay the cost
|
|
|
|
# of never using cache on unprotected branches.
|
|
|
|
#
|
|
|
|
# As such disable the first rule below and only consider CI_NODE_TOTAL and
|
|
|
|
# CI_NODE_INDEX in cache pull/pull-push preference.
|
|
|
|
#
|
|
|
|
# - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
|
|
|
# variables:
|
|
|
|
# # Dependencies change rarely so not having to worry about pushes from other branches removes complexity.
|
|
|
|
# POLICY: pull
|
2025-01-30 08:10:22 +01:00
|
|
|
- if: $CI_NODE_TOTAL == "1"
|
|
|
|
variables:
|
|
|
|
# For sequential jobs we can always push to the cache.
|
|
|
|
POLICY: pull-push
|
|
|
|
- if: $CI_NODE_INDEX == "1"
|
|
|
|
variables:
|
|
|
|
# For parallel jobs, only the first job pushes to the cache.
|
|
|
|
POLICY: pull-push
|
2025-01-30 14:40:30 +01:00
|
|
|
- if: $CI_NODE_TOTAL != "1" && $CI_NODE_INDEX != "1"
|
|
|
|
variables:
|
|
|
|
POLICY: pull
|
2025-01-30 08:10:22 +01:00
|
|
|
|
|
|
|
.spread-x86_64:
|
|
|
|
extends: .spread
|
|
|
|
tags:
|
|
|
|
- linux
|
|
|
|
- x86_64
|
|
|
|
- kvm
|
|
|
|
variables:
|
|
|
|
SPREAD_GOARCH: amd64
|
|
|
|
ARCH: x86_64
|
|
|
|
|
|
|
|
spread-ubuntu-cloud-24.04-x86_64:
|
|
|
|
extends: .spread-x86_64
|
|
|
|
variables:
|
|
|
|
GARDEN_SYSTEM: ubuntu-cloud-24.04
|
|
|
|
SPREAD_ARGS: garden:$GARDEN_SYSTEM:tests/regression/ garden:$GARDEN_SYSTEM:tests/profiles/
|
|
|
|
needs: []
|
|
|
|
dependencies: []
|
|
|
|
parallel: 4
|