Skip to content

Commit

Permalink
Merge branch 'mr/new_ci' into 'master'
Browse files Browse the repository at this point in the history
Improve CI

See merge request eng/toolchain/gnatcoll-core!71
  • Loading branch information
Nikokrock committed Feb 15, 2024
2 parents 0e5aed9 + c1dc084 commit 064e4f6
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 34 deletions.
107 changes: 76 additions & 31 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ variables:

stages:
- build
- test

default:
before_script: |
Expand Down Expand Up @@ -63,54 +62,100 @@ default:
.job_template:
services:
- image:e3
- cpu:8
- mem:16
- cpu:4
interruptible: true

.test_template:
extends: .job_template
stage: test
needs: ["build"]
allow_failure: true

########
# JOBS #
########

build:
extends: .job_template
build_doc:
services:
- image:e3
- cpu:2
stage: build
script:
- anod vcs --add-repo gnatcoll-core $CI_PROJECT_DIR
- anod build --latest gnatcoll-core-doc
- anod build --latest gnatcoll-core

- echo "packaging $ANOD_DEFAULT_SANDBOX_DIR/$HOST/gnatcoll-core-current/install/" ;
- tar czf $CI_PROJECT_DIR/gnatcoll-core-current.tar.gz -C $ANOD_DEFAULT_SANDBOX_DIR/$HOST/gnatcoll-core-current/ install/ ;
- cd $CI_PROJECT_DIR
- ls -l *.tar.gz
build-windows:
services:
- image:e3
- cpu:2
stage: build
script:
- anod install gcc --target=x86_64-windows64
- anod install gcc --target=x86-windows
- anod install gcc
- anod install gprbuild
# Native gcc is needed to get ar. otherwise gprbuild fails
- export PATH=$ANOD_DEFAULT_SANDBOX_DIR/x86_64-linux/gcc/install/bin:$PATH
- export PATH=$ANOD_DEFAULT_SANDBOX_DIR/x86_64-windows64-linux64/gcc/install/bin:$PATH
- export PATH=$ANOD_DEFAULT_SANDBOX_DIR/x86-windows-linux64/gcc/install/bin:$PATH
- export PATH=$ANOD_DEFAULT_SANDBOX_DIR/x86_64-linux/gprbuild/install/bin:$PATH
- cd $CI_PROJECT_DIR && make TARGET=x86_64-w64-mingw32 GNATCOLL_PROJECTS=no
- cd $CI_PROJECT_DIR && rm -rf lib obj
- cd $CI_PROJECT_DIR && make TARGET=i686-pc-mingw32 GNATCOLL_PROJECTS=no

build_and_test_aarch64_linux:
services:
- image:e3-aarch64-linux
- cpu:4
- platform:aarch64-linux
stage: build
script:
- anod vcs --add-repo gnatcoll-core $CI_PROJECT_DIR
- anod build --latest gnatcoll-core
- anod test --latest gnatcoll-core -Qexternal
- e3-testsuite-report
--failure-exit-code 1
--xunit-output $CI_PROJECT_DIR/test.xml
--xunit-name gnatcoll-core
$ANOD_DEFAULT_SANDBOX_DIR/aarch64-linux/gnatcoll-core_external_test/results/new/ || FAILED=true

# We previously prevented the pipeline from halting if a test failed, to make
# sure all tests were run. If a test failed now we exit with a non-zero code
- if [ "$FAILED" = "true" ]; then echo "There was at least one testcase failure" && exit 1; fi
allow_failure: true
artifacts:
when:
always
paths:
- gnatcoll-core-current.tar.gz
- test.xml
reports:
junit: test.xml

test:
extends: .test_template
build_and_test_x86_linux:
extends: .job_template
stage: build
script:
# unpack the packages
- cd $ANOD_DEFAULT_SANDBOX_DIR
- mkdir -p fingerprints
- mkdir -p $HOST/gnatcoll-core-current
- tar zxf $CI_PROJECT_DIR/gnatcoll-core-current.tar.gz -C $HOST/gnatcoll-core-current
- touch fingerprints/$HOST.gnatcoll-core-current.install.json.assume-unchanged
- touch fingerprints/$HOST.gnatcoll-core-current.download-bin.json.assume-unchanged
- cp /it/e3/lib/python3.11/site-packages/e3/os/data/rlimit-x86_64-linux /it/e3/lib/python3.11/site-packages/e3/os/data/rlimit-x86-linux
- anod vcs --add-repo gnatcoll-core $CI_PROJECT_DIR
- anod build --latest --build=x86-linux gnatcoll-core
- anod test --latest --build=x86-linux gnatcoll-core -Qexternal
- e3-testsuite-report
--failure-exit-code 1
--xunit-output $CI_PROJECT_DIR/test.xml
--xunit-name gnatcoll-core
$ANOD_DEFAULT_SANDBOX_DIR/x86-linux/gnatcoll-core_external_test/results/new/ || FAILED=true

- rm -f $CI_PROJECT_DIR/*.tar.gz
# We previously prevented the pipeline from halting if a test failed, to make
# sure all tests were run. If a test failed now we exit with a non-zero code
- if [ "$FAILED" = "true" ]; then echo "There was at least one testcase failure" && exit 1; fi
artifacts:
when:
always
paths:
- test.xml
reports:
junit: test.xml

build_and_test_x86_64_linux:
extends: .job_template
stage: build
script:
- anod vcs --add-repo gnatcoll-core $CI_PROJECT_DIR

# -Qexternal is required to use the version built outside the compiler during
# the build stage.
- anod build --latest gnatcoll-core
- anod test --latest gnatcoll-core -Qexternal
- e3-testsuite-report
--failure-exit-code 1
Expand All @@ -120,7 +165,7 @@ test:

# We previously prevented the pipeline from halting if a test failed, to make
# sure all tests were run. If a test failed now we exit with a non-zero code
- if [ ! -z ${FAILED+x} ]; then echo "There was at least one testcase failure" && exit 1; fi
- if [ "$FAILED" = "true" ]; then echo "There was at least one testcase failure" && exit 1; fi
artifacts:
when:
always
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ else
endif

ifeq ($(GNATCOV), yes)
$(GNATCOV_PROJECT_PATH) gnatcov instrument -P $(GNATCOLL_CORE_GPR) $(RBD) \
$(GNATCOV_PROJECT_PATH) gnatcov instrument -P $(GNATCOLL_CORE_GPR) $(GPR_VARS) $(RBD) \
--no-subprojects --level=stmt+decision
endif
$(BUILDER) -XLIBRARY_TYPE=$* -XXMLADA_BUILD=$* -XGPR_BUILD=$* \
Expand Down
16 changes: 14 additions & 2 deletions testsuite/drivers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ def gprbuild(
if driver.env.gnatcov:
from drivers.gnatcov import COVERAGE_LEVEL

# As gnatcoll project is taken from source dir, ensure important
# project variables are passed to select right implementations. This
# should stay in sync with the Makefile logic
gnatcoll_config_vars = []
if driver.env.target.platform in ("x86_64-linux",
"x86_64-windows64",
"aarch64-linux"):
platform = driver.env.target.platform.replace("windows64", "windows")
gnatcoll_config_vars.append(f"-XGNATCOLL_BLAKE3_ARCH={platform}")
if driver.env.target.platform in ("x86_64-linux", "x86_64-windows64"):
gnatcoll_config_vars.append(f"-XGNATCOLL_XXHASH_ARCH=x86_64")

gnatcov_cmd = [
"gnatcov",
"instrument",
Expand All @@ -151,7 +163,7 @@ def gprbuild(
"--no-subprojects",
"-P",
project_file,
] + scenario_cmd
] + gnatcoll_config_vars + scenario_cmd

check_call(
driver,
Expand All @@ -171,7 +183,7 @@ def gprbuild(
"--implicit-with=gnatcov_rts",
"-XLIBRARY_TYPE=static",
"-XEXTERNALLY_BUILT=true",
]
] + gnatcoll_config_vars

if driver.env.is_cross:
gprbuild_cmd.append(
Expand Down

0 comments on commit 064e4f6

Please sign in to comment.