Skip to content

Commit

Permalink
Move CI commands to the common bash script
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 Feb 28, 2024
1 parent ac01eb3 commit 6a03a49
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 154 deletions.
75 changes: 5 additions & 70 deletions .ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

stages:
- test
- examples
- build_docs
- deploy_docs

Expand All @@ -14,90 +13,26 @@ lint:
stage: test
tags: ['ace-x86_64']
image: debian:bookworm
before_script:
- 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
script:
- pip install ".[lint]"
- nox -s isort_check black_check flake8
- ./.github/scripts/test.sh lint

.generate_example:
stage: examples
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
git
python3-dev
python3-venv
python3-pip
- python3 -m venv venv
- source venv/bin/activate
- python3 -m pip install git+https://github.com/antmicro/tuttest
- tuttest README.md | bash -
script:
- cd examples/$EXAMPLE
- tuttest README.md install-deps,generate | bash -
- ./.github/scripts/test.sh examples

tests:
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
curl
wget
git
python3-dev
python3-venv
python3-pip
make
meson
ninja-build
gcc-riscv64-unknown-elf
bsdextrautils
verilator
libssl-dev
libreadline-dev
libffi-dev
libbz2-dev
libncurses-dev
libsqlite3-dev
liblzma-dev
- python3 -m venv venv
- source venv/bin/activate
- python3 -m pip install nox
- python3 -m pip install git+https://github.com/antmicro/tuttest
- tuttest README.md | bash -
script:
- nox -s tests_with_reports_in_env

example_hdmi:
extends: .generate_example
variables:
EXAMPLE: hdmi

example_inout:
extends: .generate_example
variables:
EXAMPLE: inout

example_pwm:
extends: .generate_example
variables:
EXAMPLE: pwm
- ./.github/scripts/test.sh tests

include:
- project: 'repositories/topwrap'
Expand Down
127 changes: 127 additions & 0 deletions .github/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/bin/bash

set -e

ROOT_DIR="$(dirname "${BASH_SOURCE[0]}")/../.."
EXAMPLES="$(ls $ROOT_DIR/examples)"

install_system_packages() {
echo "::group::Install system packages"
apt-get update -qq
apt-get install -y --no-install-recommends \
git \
python3-pip \
python3-venv

if [[ "$1" == "examples" ]] then
apt-get install -y --no-install-recommends \
python3-dev
fi

if [[ "$1" == "tests" ]] then
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
fi
echo "::endgroup::"
}

install_pyenv() {
echo "::group::Install pyenv"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
curl https://pyenv.run | bash
echo "::endgroup::"
}

enter_venv() {
echo "::group::Configure Python virtual environment"
if [[ -z "$VIRTUAL_ENV" ]] then
python3 -m venv venv
fi
source venv/bin/activate
echo "::endgroup::"
}

install_python_packages() {
echo "::group::Install Python packages"
if [[ "$1" == "lint" || "$1" == "tests" ]] then
pip install ".[$1]"
fi

if [[ "$1" == "tests" || "$1" == "examples" ]] then
pip install git+https://github.com/antmicro/tuttest
fi
echo "::endgroup::"
}

install_topwrap() {
echo "::group::Install Topwrap"
tuttest README.md | bash -
echo "::endgroup::"
}

run_lint() {
install_system_packages
enter_venv
install_python_packages "lint"

echo "::group::Run lint checks"
nox -s isort_check black_check flake8
echo "::endgroup::"
}

run_tests() {
install_system_packages "tests"
install_pyenv
enter_venv
install_python_packages "tests"
install_topwrap

echo "::group::Run Python tests"
nox -s tests_with_reports_in_env
echo "::endgroup::"
}

generate_examples() {
install_system_packages "examples"
enter_venv
install_python_packages "examples"
install_topwrap

for EXAMPLE in $EXAMPLES; do
echo "::group::Generate $EXAMPLE example"
cd examples/$EXAMPLE;
tuttest README.md install-deps,generate | bash -;
echo "::endgroup::"
done
}

case "$1" in
lint)
run_lint
;;
tests)
run_tests
;;
examples)
generate_examples
;;
*)
echo "Usage: $0 {lint|tests|examples}"
;;
esac
100 changes: 16 additions & 84 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,18 @@ jobs:
name: "Run lint checks"

steps:
- name: Install system packages
- name: Install git package
run: |
apt-get update -qq
apt-get install -y --no-install-recommends \
git \
python3-pip \
python3-venv
apt-get install -y --no-install-recommends git
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

- name: Install Python dependencies
run: |
python3 -m venv venv
source venv/bin/activate
pip install -U pip wheel setuptools
- name: Run lint checks
run: |
source venv/bin/activate
pip install ".[lint]"
nox -s isort_check black_check flake8
./.github/scripts/test.sh lint
tests:
runs-on: ubuntu-latest
Expand All @@ -51,90 +40,33 @@ jobs:
name: "Run tests"

steps:
- name: Install system packages
- name: Install git package
run: |
apt-get update -qq
apt-get install -y --no-install-recommends \
curl \
wget \
git \
python3-dev \
python3-venv \
python3-pip \
make \
meson \
ninja-build \
gcc-riscv64-unknown-elf \
bsdextrautils \
verilator \
libssl-dev \
libreadline-dev \
libffi-dev \
libbz2-dev \
libncurses-dev \
libsqlite3-dev \
liblzma-dev
- uses: actions/checkout@v3
apt-get install -y --no-install-recommends git
- uses: actions/checkout@v4
with:
submodules: true

- name: Install Python dependencies
run: |
python3 -m venv venv
source venv/bin/activate
pip install nox
pip install git+https://github.com/antmicro/tuttest
- name: Build
run: |
source venv/bin/activate
tuttest README.md | bash -
- name: Run pytest with nox
- name: Run Python tests
run: |
source venv/bin/activate
nox -s tests_with_reports_in_env
./.github/scripts/test.sh tests
examples:
runs-on: ubuntu-latest
container:
image: debian:bookworm
name: 'Generate example ${{ matrix.example }}'

strategy:
fail-fast: false
matrix:
example:
- hdmi
- inout
- pwm
name: 'Generate examples'

steps:
- name: Install system packages
- name: Install git package
run: |
apt-get update -qq
apt-get install -y --no-install-recommends \
git \
python3-dev \
python3-venv \
python3-pip
- uses: actions/checkout@v3
apt-get install -y --no-install-recommends git
- name: Install Python dependencies
run: |
python3 -m venv venv
source venv/bin/activate
pip install git+https://github.com/antmicro/tuttest
- name: Install fpga-topwrap
run: |
source venv/bin/activate
tuttest README.md | bash -
- uses: actions/checkout@v4

- name: Generate sources for example ${{ matrix.example }} setup
- name: Generate Topwrap examples
run: |
source venv/bin/activate
cd examples/${{ matrix.example }}
tuttest README.md install-deps,generate | bash -
./.github/scripts/test.sh examples

0 comments on commit 6a03a49

Please sign in to comment.