Skip to content

Commit

Permalink
Unify Github and Gitlab CIs
Browse files Browse the repository at this point in the history
Internal-tag: [#53659]
Signed-off-by: Robert Szczepanski <[email protected]>
  • Loading branch information
robertszczepanski committed Mar 8, 2024
1 parent 3a6b594 commit eb59287
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 147 deletions.
65 changes: 28 additions & 37 deletions .ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,48 @@

stages:
- test
- build
- deploy
- build_docs
- deploy_docs

image: debian:bookworm
variables:
DEBIAN_FRONTEND: noninteractive

lint:
stage: test
tags: ['ace-x86_64']
before_script: &BeforeScript
- apt-get update -qq
- apt-get install -y --no-install-recommends git python3-pip python3-venv
- python3 -m venv venv
- source venv/bin/activate
- python3 -m pip install -U pip wheel setuptools
image: debian:bookworm
script:
- pip install ".[lint]"
- nox -s isort_check black_check flake8
- ./.github/scripts/ci.sh lint

pytest:
examples:
stage: test
tags: ['ace-x86_64']
image: debian:bookworm
variables:
GIT_SUBMODULE_STRATEGY: normal
before_script:
- apt-get update -qq
- apt-get install -y --no-install-recommends wget git python3-dev python3-venv make ninja-build gcc-riscv64-unknown-elf bsdextrautils verilator
- mkdir -p miniconda3
- wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda3/miniconda.sh
- bash miniconda3/miniconda.sh -b -u -p miniconda3
- rm -rf miniconda3/miniconda.sh
- source miniconda3/bin/activate
- conda create -n venv python=3.9
- conda activate venv
- conda install -c conda-forge gcc=12.1.0
script:
- apt-get install -y --no-install-recommends git python3-dev
- python3 -m pip install git+https://github.com/antmicro/tuttest
- tuttest README.md | bash -
- pip install ".[tests]"
- nox -s tests_with_report
- ./.github/scripts/ci.sh examples
artifacts:
paths:
- cov_html
- examples/**/build

docs-verify:
tests:
stage: test
tags: ['ace-x86_64']
image: debian:bookworm
variables:
GIT_SUBMODULE_STRATEGY: normal
script:
- eval ${VERIFY_SCRIPT}
- ./.github/scripts/ci.sh tests

docs-build:
include:
- project: 'repositories/topwrap'
ref: internal_ci_yaml
file: '/internal.yml'

build_docs:
image: $CI_DOCS_DOCKER_IMAGE
stage: build
stage: build_docs
tags: ['ace-x86_64']
before_script:
- pip3 install -r docs/requirements.txt
Expand All @@ -64,20 +53,22 @@ docs-build:
- echo -en "\nhtml_js_files = [ '$ANNOTANT' ]" >> source/conf.py
- make html latexpdf
- cp build/latex/*.pdf build/html/
- cp -r ../cov_html build/html/cov
- tar cf ../$CI_DOCS_ARCHIVE -C build/html/ .
artifacts:
paths:
- docs/build
- $CI_DOCS_ARCHIVE

docs-deploy:
deploy_docs:
image: $CI_DOCS_DOCKER_IMAGE
variables:
GIT_STRATEGY: none
dependencies: [ docs-build ]
stage: deploy
dependencies:
- build_docs
stage: deploy_docs
tags: ['docs']
script: echo 'Deploying docs'
artifacts:
paths:
- $CI_DOCS_ARCHIVE

150 changes: 150 additions & 0 deletions .github/scripts/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#!/bin/bash
# Copyright (c) 2024 Antmicro <www.antmicro.com>
# SPDX-License-Identifier: Apache-2.0

set -e

ROOT_DIR="$(dirname "${BASH_SOURCE[0]}")/../.."
EXAMPLES=(hdmi inout pwm)

begin_command_group() {
if [[ -n "${GITHUB_WORKFLOW:-}" ]]; then
echo "::group::$*"
else
echo -e "\n\033[1;92mRunning step: $1\033[0m\n"
fi
}

end_command_group() {
if [[ -n "${GITHUB_WORKFLOW:-}" ]]; then
echo "::endgroup::"
fi
}

log_cmd() {
printf '\033[1;96m'
printf '%s ' "$*"
printf '\033[0m\n'
eval "$*"
}

install_common_system_packages() {
begin_command_group "Install system packages"
log_cmd apt-get update -qq
log_cmd apt-get install -y --no-install-recommends \
git \
python3-pip \
python3-venv
end_command_group
}

install_pyenv() {
begin_command_group "Install pyenv"
log_cmd export PYENV_ROOT="$HOME/.pyenv"
log_cmd export PATH="$PYENV_ROOT/bin:$PATH"
log_cmd "curl https://pyenv.run | bash"
end_command_group
}

enter_venv() {
begin_command_group "Configure Python virtual environment"
if [[ -z "$VIRTUAL_ENV" ]]; then
log_cmd python3 -m venv venv
fi
log_cmd source venv/bin/activate
end_command_group
}

install_topwrap() {
begin_command_group "Install Topwrap"
log_cmd "tuttest README.md | bash -"
end_command_group
}

run_lint() {
install_common_system_packages
enter_venv

begin_command_group "Install python packages for lint"
log_cmd pip install ".[lint]"
end_command_group

begin_command_group "Run lint checks"
log_cmd nox -s isort_check black_check flake8
end_command_group
}

run_tests() {
install_common_system_packages

begin_command_group "Install system packages for tests"
log_cmd apt-get install -y --no-install-recommends \
curl \
wget \
python3-dev \
make \
meson \
ninja-build \
gcc-riscv64-unknown-elf \
bsdextrautils \
verilator \
libssl-dev \
libreadline-dev \
libffi-dev \
libbz2-dev \
libncurses-dev \
libsqlite3-dev \
liblzma-dev
end_command_group

install_pyenv
enter_venv

begin_command_group "Install python packages for tests"
log_cmd pip install ".[tests]"
log_cmd pip install git+https://github.com/antmicro/tuttest
end_command_group

install_topwrap

begin_command_group "Run Python tests"
log_cmd nox -s tests_in_env
end_command_group
}

generate_examples() {
install_common_system_packages
begin_command_group "Install system packages for examples"
log_cmd apt-get install -y --no-install-recommends python3-dev
end_command_group
enter_venv

begin_command_group "Install python packages for examples"
log_cmd pip install git+https://github.com/antmicro/tuttest
end_command_group

install_topwrap

for EXAMPLE in "${EXAMPLES[@]}"; do
begin_command_group "Generate $EXAMPLE example"
log_cmd pushd "$ROOT_DIR"/examples/"$EXAMPLE"
log_cmd "tuttest README.md install-deps,generate | bash -"
log_cmd popd
end_command_group
done
}

case "$1" in
lint)
run_lint
;;
tests)
run_tests
;;
examples)
generate_examples
;;
*)
echo "Usage: $0 {lint|tests|examples}"
;;
esac
14 changes: 0 additions & 14 deletions .github/scripts/latex.sh

This file was deleted.

12 changes: 0 additions & 12 deletions .github/scripts/sphinx.sh

This file was deleted.

Loading

0 comments on commit eb59287

Please sign in to comment.