Skip to content

Commit

Permalink
Merge pull request #5592 from edwintorok/private/edvint/speedci
Browse files Browse the repository at this point in the history
Speed up CI
  • Loading branch information
edwintorok authored Apr 26, 2024
2 parents 09b4bdb + 15391c9 commit 63e0377
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 148 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/cleanup-xapi-environment/action.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/generate-and-build-sdks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ jobs:
name: SDK_Source_PowerShell
path: _build/install/default/xapi/sdk/powershell/*

- name: Cleanup XenAPI environment
uses: ./.github/workflows/cleanup-xapi-environment
- name: Trim dune cache
run: opam exec -- dune cache trim --size=2GiB

build-c-sdk:
name: Build C SDK
Expand Down
132 changes: 3 additions & 129 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,112 +12,9 @@ concurrency: # On new push, cancel old workflows from the same PR, branch or tag
cancel-in-progress: true

jobs:
python-test:
name: Python tests
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ["2.7", "3.11"]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
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@v4
name: Setup cache for running pre-commit fast
with:
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"

- uses: pre-commit/[email protected]
name: Run pre-commit checks (no spaces at end of lines, etc)
if: ${{ matrix.python-version != '2.7' }}
with:
extra_args: --all-files --verbose --hook-stage commit
env:
SKIP: no-commit-to-branch

- name: Install dependencies only needed for python 2
if: ${{ matrix.python-version == '2.7' }}
run: pip install enum

- name: Install dependencies only needed for python 3
if: ${{ matrix.python-version != '2.7' }}
run: pip install opentelemetry-api opentelemetry-exporter-zipkin-json opentelemetry-sdk pandas pytype toml wrapt

- name: Install common dependencies for Python ${{matrix.python-version}}
run: pip install future mock pytest-coverage pytest-mock

- name: Run Pytest for python 2 and get code coverage for Codecov
if: ${{ matrix.python-version == '2.7' }}
run: >
pytest
--cov=scripts --cov=ocaml/xcp-rrdd
scripts/ ocaml/xcp-rrdd -vv -rA
--junitxml=.git/pytest${{matrix.python-version}}.xml
--cov-report term-missing
--cov-report xml:.git/coverage${{matrix.python-version}}.xml
env:
PYTHONDEVMODE: yes

- name: Run Pytest for python 3 and get code coverage for Codecov
if: ${{ matrix.python-version != '2.7' }}
run: >
pytest
--cov=scripts --cov=ocaml/xcp-rrdd --cov=python3/
scripts/ ocaml/xcp-rrdd python3/ -vv -rA
--junitxml=.git/pytest${{matrix.python-version}}.xml
--cov-report term-missing
--cov-report xml:.git/coverage${{matrix.python-version}}.xml
env:
PYTHONDEVMODE: yes

- name: Upload Python ${{matrix.python-version}} coverage report to Codecov
uses: codecov/codecov-action@v3
with:
directory: .git
files: coverage${{matrix.python-version}}.xml
env_vars: OS,PYTHON
fail_ci_if_error: false
flags: python${{matrix.python-version}}
name: coverage${{matrix.python-version}}
verbose: true

- uses: dciborow/[email protected]
if: ${{ matrix.python-version != '2.7' }}
with:
reporter: github-pr-review
level: warning
# To be customized to cover remaining Python scripts:
glob_pattern: "**/*.py"
continue-on-error: true

- name: Run pytype checks
if: ${{ matrix.python-version != '2.7' }}
run: ./pytype_reporter.py
env:
PR_NUMBER: ${{ github.event.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYTYPE_REPORTER_DEBUG: True

- name: pyflakes
uses: reviewdog/action-pyflakes@v1
with:
github_token: ${{ secrets.github_token }}
continue-on-error: true


ocaml-tests:
name: Run OCaml tests
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
# Ensure you also update test-sdk-builds
# when changing this value, to keep builds
Expand Down Expand Up @@ -153,28 +50,5 @@ jobs:
- name: Check disk space
run: df -h || true

- name: Cleanup XenAPI environment
uses: ./.github/workflows/cleanup-xapi-environment

deprecation-test:
name: Deprecation tests
runs-on: ubuntu-20.04

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

- name: Generate empty configuration for make to be happy
run: touch config.mk

- name: quality-gate
run: make quality-gate

test-sdk-builds:
name: Test SDK builds
uses: ./.github/workflows/generate-and-build-sdks.yml
with:
# Ensure you also update ocaml-tests
# when changing this value, to keep builds
# consistent
xapi_version: "v0.0.0"
- name: Trim dune cache
run: opam exec -- dune cache trim --size=2GiB
138 changes: 138 additions & 0 deletions .github/workflows/other.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Build and test (other)

on:
push:
pull_request:
schedule:
# run daily, this refreshes the cache
- cron: "13 2 * * *"

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

jobs:
python-test:
name: Python tests
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ["2.7", "3.11"]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
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@v4
name: Setup cache for running pre-commit fast
with:
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"

- uses: pre-commit/[email protected]
name: Run pre-commit checks (no spaces at end of lines, etc)
if: ${{ matrix.python-version != '2.7' }}
with:
extra_args: --all-files --verbose --hook-stage commit
env:
SKIP: no-commit-to-branch

- name: Install dependencies only needed for python 2
if: ${{ matrix.python-version == '2.7' }}
run: pip install enum

- name: Install dependencies only needed for python 3
if: ${{ matrix.python-version != '2.7' }}
run: pip install opentelemetry-api opentelemetry-exporter-zipkin-json opentelemetry-sdk pandas pytype toml wrapt

- name: Install common dependencies for Python ${{matrix.python-version}}
run: pip install future mock pytest-coverage pytest-mock

- name: Run Pytest for python 2 and get code coverage for Codecov
if: ${{ matrix.python-version == '2.7' }}
run: >
pytest
--cov=scripts --cov=ocaml/xcp-rrdd
scripts/ ocaml/xcp-rrdd -vv -rA
--junitxml=.git/pytest${{matrix.python-version}}.xml
--cov-report term-missing
--cov-report xml:.git/coverage${{matrix.python-version}}.xml
env:
PYTHONDEVMODE: yes

- name: Run Pytest for python 3 and get code coverage for Codecov
if: ${{ matrix.python-version != '2.7' }}
run: >
pytest
--cov=scripts --cov=ocaml/xcp-rrdd --cov=python3/
scripts/ ocaml/xcp-rrdd python3/ -vv -rA
--junitxml=.git/pytest${{matrix.python-version}}.xml
--cov-report term-missing
--cov-report xml:.git/coverage${{matrix.python-version}}.xml
env:
PYTHONDEVMODE: yes

- name: Upload Python ${{matrix.python-version}} coverage report to Codecov
uses: codecov/codecov-action@v3
with:
directory: .git
files: coverage${{matrix.python-version}}.xml
env_vars: OS,PYTHON
fail_ci_if_error: false
flags: python${{matrix.python-version}}
name: coverage${{matrix.python-version}}
verbose: true

- uses: dciborow/[email protected]
if: ${{ matrix.python-version != '2.7' }}
with:
reporter: github-pr-review
level: warning
# To be customized to cover remaining Python scripts:
glob_pattern: "**/*.py"
continue-on-error: true

- name: Run pytype checks
if: ${{ matrix.python-version != '2.7' }}
run: ./pytype_reporter.py
env:
PR_NUMBER: ${{ github.event.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYTYPE_REPORTER_DEBUG: True

- name: pyflakes
uses: reviewdog/action-pyflakes@v1
with:
github_token: ${{ secrets.github_token }}
continue-on-error: true

deprecation-test:
name: Deprecation tests
runs-on: ubuntu-22.04

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

- name: Generate empty configuration for make to be happy
run: touch config.mk

- name: quality-gate
run: make quality-gate

test-sdk-builds:
name: Test SDK builds
uses: ./.github/workflows/generate-and-build-sdks.yml
with:
# Ensure you also update ocaml-tests
# when changing this value, to keep builds
# consistent
xapi_version: "v0.0.0"
13 changes: 9 additions & 4 deletions .github/workflows/setup-xapi-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ inputs:
runs:
using: "composite"
steps:
- name: Free space
shell: bash
run: sudo rm -rf /usr/local/lib/android

- name: Pull configuration from xs-opam
shell: bash
run: |
Expand All @@ -31,6 +27,10 @@ runs:
shell: bash
run: sudo apt-get update

- name: Install python2
shell: bash
run: sudo apt-get install python2

- name: Use disk with more space for TMPDIR and XDG_CACHE_HOME
shell: bash
run: |
Expand All @@ -42,13 +42,18 @@ runs:
echo "TMPDIR=${TMPDIR}" >>"$GITHUB_ENV"
echo "XDG_CACHE_HOME=${XDG_CACHE_HOME}" >>"$GITHUB_ENV"
# We set DUNE_CACHE_STORAGE_MODE, it is required for dune cache to work inside opam for now,
# otherwise it gets EXDEV and considers it a cache miss
- name: Use ocaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ steps.dotenv.outputs.ocaml_version_full }}
opam-repositories: |
xs-opam: ${{ steps.dotenv.outputs.repository }}
opam-pin: false
dune-cache: true
env:
DUNE_CACHE_STORAGE_MODE: copy

- name: Install dependencies
shell: bash
Expand Down

0 comments on commit 63e0377

Please sign in to comment.