Skip to content
Snippets Groups Projects
Commit d7086104 authored by Anya Helene Bagge's avatar Anya Helene Bagge
Browse files

initial

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #183500 failed
stages:
- build
- test
#variables:
# CI_REGISTRY: "git.app.uib.no:4567/ii/inf222/v23/assignments/test-runner:latest"
#include:
# - template: Security/Secret-Detection.gitlab-ci.yml
# - template: Code-Quality.gitlab-ci.yml
workflow:
rules:
# run a merge request pipeline if that makes sense
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
# don't run a branch pipeline on commits if we'll run a merge request pipeline
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
# do run a branch pipeline for other commits
- if: '$CI_COMMIT_BRANCH'
# rules:
# - changes:
# - src/**/*
# - pom.xml
# Use Maven 3.8.4 on OpenJDK 17 with 'slim' Ubuntu
image: git.app.uib.no:4567/ii/inf222/v23/assignments/test-runner:latest
#before_script:
# - docker login -p "$CI_JOB_TOKEN" $CI_REGISTRY
# - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
#cache:
# paths:
# - build
# key: "$CI_JOB_NAME"
# run mvn compile to build the project
build:
stage: build
script:
- env
- './run-tests compile'
artifacts:
paths:
- build/
exclude:
- build/**/*.o
- build/**/*.hi
expire_in: 1 hour
# run mvn verify to compile and test the project
test:
stage: test
script:
- './run-tests test'
artifacts:
paths:
- report/
when: always
name: test-report
reports:
junit: report/*.xml
expire_in: 1 month
# coverage: '/Total.*?([0-9]{1,3})%/'
dependencies:
- build
FROM haskell:9-slim-buster AS haskell-base
ARG GHC
RUN rm -rf /opt/ghc/*/share/doc
FROM debian:buster-slim AS haskell-main
# common haskell + stack dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends tzdata \
ca-certificates curl dpkg-dev git gcc gnupg g++ libc6-dev \
libffi-dev libgmp-dev libnuma-dev libtinfo-dev make netbase xz-utils zlib1g-dev && \
rm -f /etc/localtime && ln -s /usr/share/zoneinfo/Europe/Oslo /etc/localtime && echo Europe/Oslo > /etc/timezone && \
rm -rf /var/lib/apt/lists/* || true
COPY --from=haskell-base /opt /opt
COPY --from=haskell-base /usr/local /usr/local
RUN ln -s /opt/ghc/*/bin/* /usr/local/bin/
RUN addgroup --system curry && adduser --system --ingroup curry --home /home/curry curry
USER curry
WORKDIR /home/curry
#ENV PATH /home/curry/bin:/home/curry/.local/bin:/opt/ghc/${GHC}/bin:$PATH
#Haskell dependencies
RUN cabal update \
&& cabal install --lib QuickCheck \
&& cabal install --lib tasty \
&& cabal install --lib tasty-quickcheck \
&& cabal install --lib tasty-hunit \
&& cabal install --lib tasty-ant-xml \
&& cabal install --lib bytestring \
&& cabal install --lib tasty-html \
; rm -f .cabal/packages/hackage.haskell.org/01-*
COPY --chown=curry:curry . /home/curry/
CMD ["/home/curry/run-tests", "setup", "compile", "test"]
#! /bin/sh
cd /tmp
git clone https://token:$TEST_ACCESS_TOKEN@git.app.uib.no/ii/inf222/v23/assignments/$TEST_PROJECT_NAME.git testcode
run-tests 0 → 100755
#! /bin/sh
# Automatic test script
#
# Author: Sander Wiig (swi028@uib.no) & Anya Bagge (anya@ii.uib.no)
#
# Usage: run-tests [compile] [test]
#
SUCCESSES=0
FAILURES=0
compile()
{
echo "----------------------------------------"
echo "==========Compiling Test Files=========="
echo "----------------------------------------"
for i in $(cd "$TEST_DIR"; find . -name '*_Test*.hs'); do
i="${i#./}" # strip leading ./
o="${i%.hs}" # strip trailing .hs
mkdir -p "$BUILD_DIR/$(dirname $o)"
echo "--Compiling $i to $o---"
if ghc -i"$STUDENT_DIR" --make "$TEST_DIR/$i" -o "$BUILD_DIR/$o"; then
SUCCESSES=$(( SUCCESSES + 1 ))
else
FAILURES=$(( FAILURES + 1 ))
fi
done
}
#runs Test files
#Test files have form {assignment}_Test{taskNumber}
run_tests()
{
#echo "----------------------------------------"
#echo "==============Running Test=============="
#echo "----------------------------------------"
[ -d "$REPORT_DIR" ] || mkdir -p "$REPORT_DIR"
for i in $(cd "$BUILD_DIR" && find . -type f -name \*Test\* -executable ); do #Only run compiled program
i="${i#./}"
o=$(echo "$i" | sed -e 's;/;_;g') # / → _
echo "$i$o"
if "$BUILD_DIR/$i" --xml="$REPORT_DIR/$o.xml" --html="$REPORT_DIR/$o.html" --color=never; then
SUCCESSES=$(( SUCCESSES + 1 ))
else
FAILURES=$(( FAILURES + 1 ))
fi
#echo "----------------------------------------"
done
echo
}
#echo "========================================"
#echo "@-----------------TEST-----------------@"
#echo "========================================"
#options
STUDENT_DIR=.
TEST_DIR=/tmp/testcode
REPORT_DIR=report
BUILD_DIR=build
#[ $# -ge 1 ] && STUDENT_DIR=$1
#[ $# -ge 2 ] && TEST_DIR=$2
#[ $# -ge 3 ] && REPORT_DIR=$3
#STUDENT_DIR=`realpath "$STUDENT_DIR"`
#TEST_DIR=`realpath "$TEST_DIR"`
#REPORT_DIR=`realpath "$REPORT_DIR"`
#BUILD_DIR=`realpath "$TEST_DIR/../build"`
while [ $# -gt 0 ]; do
if [ "$1" = "setup" ]; then
shift
elif [ "$1" = "compile" ]; then
compile
shift
elif [ "$1" = "test" ]; then
run_tests
shift
elif [ "$1" = "-s" ]; then
shift
STUDENT_DIR="$1"
shift
elif [ "$1" = "-t" ]; then
shift
TEST_DIR="$1"
shift
else
echo >> /dev/stderr Bad argument: "$1"
echo >> /dev/stderr usage: run-tests [-t TEST_DIR] [-s STUDENT_DIR] [compile] [test]
exit 1
fi
done
echo $SUCCESSES successful tests, $FAILURES failures
echo "========================================"
echo "@-----------------DONE-----------------@"
echo "========================================"
[ $FAILURES -eq 0 ] # set exit code
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment