Build and test #60
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and test | |
on: | |
push: | |
pull_request: | |
schedule: | |
# run daily, this refreshes the cache | |
- cron: '13 2 * * *' | |
jobs: | |
python-test: | |
name: Python tests | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.11"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Use python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install python 2 dependencies | |
if: ${{ matrix.python-version == 2.7 }} | |
run: pip install enum | |
- name: Install dependencies | |
run: pip install mock pytest | |
- name: Run python tests | |
run: pytest scripts | |
ocaml-test: | |
name: Ocaml tests | |
runs-on: ubuntu-20.04 | |
env: | |
package: "xapi-cli-protocol xapi-client xapi-consts xapi-datamodel xapi-types xapi xe xen-api-sdk xen-api-client xen-api-client-lwt xen-api-client-async xapi-rrdd xapi-rrdd-plugin xapi-rrd-transport xapi-rrd-transport-utils rrd-transport rrdd-plugin rrdd-plugins rrddump gzip http-lib pciutil safe-resources sexpr stunnel uuid xapi-compression xml-light2 zstd vhd-tool xapi-networkd xapi-squeezed xapi-xenopsd xapi-xenopsd-cli xapi-xenopsd-simulator xapi-xenopsd-xc message-switch message-switch-async message-switch-cli message-switch-core message-switch-lwt message-switch-unix xapi-idl forkexec xapi-forkexecd xapi-storage xapi-storage-script xapi-storage-cli wsproxy xapi-nbd varstored-guard xapi-log xapi-open-uri vhd-format vhd-format-lwt xapi-tracing" | |
XAPI_VERSION: "v0.0.0-${{ github.sha }}" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# The checkout action performs a shallow, this triggers dune to set the | |
# version to <hash>-dirty. Work around this dune behaviour and tag the | |
# commit so a proper version is always picked up | |
- name: Tag current commit | |
run: | | |
git config user.name "Dune workaround" | |
git config user.email "<>" | |
git tag -am "workaround for dune" "$XAPI_VERSION" | |
- name: Pull configuration from xs-opam | |
run: | | |
curl --fail --silent https://raw.githubusercontent.com/xapi-project/xs-opam/master/tools/xs-opam-ci.env | cut -f2 -d " " > .env | |
- name: Load environment file | |
id: dotenv | |
uses: falti/[email protected] | |
- name: Retrieve date for cache key | |
id: cache-key | |
run: echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Restore opam cache | |
id: opam-cache | |
uses: actions/cache@v3 | |
with: | |
path: "~/.opam" | |
# invalidate cache daily, gets built daily using a scheduled job | |
key: ${{ steps.cache-key.outputs.date }} | |
- name: Use ocaml | |
uses: avsm/setup-ocaml@v1 | |
with: | |
ocaml-version: ${{ steps.dotenv.outputs.ocaml_version_full }} | |
opam-repository: ${{ steps.dotenv.outputs.repository }} | |
- name: Install dependencies | |
run: | | |
opam update | |
opam pin add . --no-action | |
opam depext -u ${{ env.package }} | |
opam upgrade | |
opam install ${{ env.package }} --deps-only --with-test -v | |
- name: Configure | |
run: opam exec -- ./configure --xapi_version="$XAPI_VERSION" | |
- name: Build | |
run: opam exec -- make | |
- name: Run tests | |
run: opam exec -- make test | |
- name: Check all code | |
run: opam exec -- make check | |
- name: Run stress tests | |
run: opam exec -- make stresstest | |
if: ${{ github.event_name == 'schedule' }} | |
- name: Build SDK | |
run: | | |
mkdir -p /opt/xensource/sm | |
wget -O /opt/xensource/sm/XE_SR_ERRORCODES.xml https://raw.githubusercontent.com/xapi-project/sm/master/drivers/XE_SR_ERRORCODES.xml | |
opam exec -- make sdk | |
- name: Uninstall unversioned packages and remove pins | |
# This should purge them from the cache, unversioned package have | |
# 'master' as its version | |
run: | | |
opam list | awk -F " " '$2 == "master" { print $1 }' | xargs opam uninstall | |
opam pin list | cut -f1 -d "." | xargs opam unpin | |
deprecation-test: | |
name: Deprecation tests | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Generate empty configuration for make to be happy | |
run: touch config.mk | |
- name: quality-gate | |
run: make quality-gate |