Skip to content

Commit

Permalink
Replace use of sdksanity with reusable workflow for testing SDKs
Browse files Browse the repository at this point in the history
Signed-off-by: Danilo Del Busso <[email protected]>
  • Loading branch information
danilo-delbusso committed Feb 16, 2024
1 parent 7820b89 commit 5313ad5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 61 deletions.
74 changes: 18 additions & 56 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ on:
pull_request:
schedule:
# run daily, this refreshes the cache
- cron: '13 2 * * *'
- cron: "13 2 * * *"

concurrency: # On new push, cancel old workflows from the same PR, branch or tag:
concurrency: # On new push, cancel old workflows from the same PR, branch or tag:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

Expand All @@ -18,21 +18,21 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['2.7', '3.11']
python-version: ["2.7", "3.11"]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # To check which files changed: origin/master..HEAD
fetch-depth: 0 # To check which files changed: origin/master..HEAD
- uses: LizardByte/setup-python-action@master
with:
python-version: ${{matrix.python-version}}

- uses: actions/cache@v3
name: Setup cache for running pre-commit fast
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
path: ~/.cache/pre-commit
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

- run: echo "::add-matcher::.github/workflows/python-warning-matcher.json"
name: "Setup GitHub for reporting Python warnings as annotations in pull request code review"
Expand Down Expand Up @@ -103,55 +103,21 @@ jobs:
# Fails for user workflows without permissions(fork-based pull requests):
continue-on-error: true
with:
message-path: .git/pytype-summary.md # Add the content of it as comment
message-path: .git/pytype-summary.md # Add the content of it as comment

ocaml-test:
name: Ocaml tests
ocaml-tests:
name: Run OCaml tests
runs-on: ubuntu-20.04
env:
XAPI_VERSION: "v0.0.0"

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Free space
run: sudo rm -rf /usr/local/lib/android

- 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: Update Ubuntu repositories
run: sudo apt-get update

- name: Use disk with more space for TMPDIR and XDG_CACHE_HOME
run: |
df -h || true
export TMPDIR="/mnt/build/tmp"
export XDG_CACHE_HOME="/mnt/build/cache"
sudo mkdir -p "${TMPDIR}" "${XDG_CACHE_HOME}"
sudo chown "$(id -u):$(id -g)" "${TMPDIR}" "${XDG_CACHE_HOME}"
echo "TMPDIR=${TMPDIR}" >>"$GITHUB_ENV"
echo "XDG_CACHE_HOME=${XDG_CACHE_HOME}" >>"$GITHUB_ENV"
- name: Use ocaml
uses: ocaml/setup-ocaml@v2
- name: Setup XenAPI environment
uses: ./.github/workflows/setup-xapi-environment
with:
ocaml-compiler: ${{ steps.dotenv.outputs.ocaml_version_full }}
opam-repositories: |
xs-opam: ${{ steps.dotenv.outputs.repository }}
dune-cache: true

- name: Install dependencies
run: opam install . --deps-only --with-test -v

- name: Configure
run: opam exec -- ./configure --xapi_version="$XAPI_VERSION"
xapi_version: ${{ env.XAPI_VERSION }}

- name: Build
run: opam exec -- make
Expand All @@ -166,21 +132,11 @@ jobs:
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: Make install smoketest
run: |
opam exec -- make install DESTDIR=$(mktemp -d)
opam exec -- make install DESTDIR=$(mktemp -d) BUILD_PY2=NO
- name: Sanity test SDK
run: |
opam exec -- make sdksanity
- name: Check disk space
run: df -h || true

Expand Down Expand Up @@ -211,3 +167,9 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error

test-sdk-builds:
name: Test SDK builds
uses: ./.github/workflows/generate-and-build-sdks.yml
with:
xapi_version: "0.0.0"
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ sdk:
sh ocaml/sdk-gen/windows-line-endings.sh $(XAPISDK)/csharp
sh ocaml/sdk-gen/windows-line-endings.sh $(XAPISDK)/powershell

# workaround for no .resx generation, just for compilation testing
sdksanity: sdk
sed -i 's/FriendlyErrorNames.ResourceManager/null/g' ./_build/install/default/xapi/sdk/csharp/src/Failure.cs
cd _build/install/default/xapi/sdk/csharp/src && dotnet add package Newtonsoft.Json && dotnet build -f netstandard2.0

.PHONY: sdk-build-java

sdk-build-java: sdk
Expand Down

0 comments on commit 5313ad5

Please sign in to comment.