Skip to content

Commit

Permalink
chore(bors): merge pull request #598
Browse files Browse the repository at this point in the history
598: refactor(pytest): make test more robust and easier to debug r=tiagolobocastro a=tiagolobocastro

    refactor(nix): make shell nix depend on other shells
    
    Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>



Co-authored-by: Tiago Castro <tiagolobocastro@gmail.com>
  • Loading branch information
mayastor-bors and tiagolobocastro committed Jan 15, 2025
2 parents d1e15a4 + 3c132b1 commit 84ae388
Show file tree
Hide file tree
Showing 30 changed files with 810 additions and 590 deletions.
61 changes: 37 additions & 24 deletions .github/workflows/k8s-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:

jobs:
k8s-ci:
runs-on: ubuntu-latest
runs-on: ubuntu-latest-16-cores
steps:
- name: Bind mount /dev/sda1 to /nix
run: |
Expand All @@ -18,39 +18,52 @@ jobs:
with:
kvm: true
- uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Pre-populate nix-shell
- name: Setup Nix Path
run: |
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
nix-shell ./scripts/k8s/shell.nix --run "echo"
- name: Build binaries and images
id: build
run: |
TAG=$(nix-shell ./shell.nix --run './scripts/python/generate-test-tag.sh')
TEST_DIR=$(realpath $(mktemp -d ./test-dir-XXXXXX))
nix-shell ./shell.nix --run "./scripts/python/tag-chart.sh $TAG"
RUSTFLAGS="-C debuginfo=0 -C strip=debuginfo" ./scripts/release.sh --tag $TAG --build-binary-out $TEST_DIR --no-static-linking --skip-publish --debug
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "bin=$TEST_DIR" >> $GITHUB_OUTPUT
- name: Pre-populate K8s nix-shell
run: nix-shell ./scripts/k8s/shell.nix --run "echo"
- name: Pre-populate helm nix-shell
run: nix-shell ./scripts/helm/shell.nix --run "echo"
- name: Pre-populate pytest nix-shell
run: nix-shell ./scripts/python/shell.nix --run "echo"
- name: BootStrap k8s cluster
run: nix-shell ./scripts/k8s/shell.nix --run "./scripts/k8s/deployer.sh start --label"
- name: Prepare v-next images and binary
run: nix-shell ./scripts/python/shell.nix --run "./scripts/python/upgrade-test-helper.sh --build --chart-tag --chart ./chart"
- name: Load images to kind cluster
run: nix-shell ./scripts/python/shell.nix --run "./scripts/python/upgrade-test-helper.sh --load"
- name: Run pytest
run: |
nix-shell ./scripts/k8s/shell.nix --run "./scripts/k8s/deployer.sh start --label"
- name: Load images to Kind cluster
run: nix-shell ./scripts/k8s/shell.nix --run "./scripts/k8s/load-images-to-kind.sh --tag ${{ steps.build.outputs.tag }} --trim-debug-suffix"
- name: Run Pytests
run: |
export UPGRADE_TARGET_VERSION=${{ steps.build.outputs.tag }}
export TEST_DIR=${{ steps.build.outputs.bin }}
nix-shell ./shell.nix --run "./scripts/python/test.sh"
- name: The job has failed
export REUSE_CLUSTER=1
export CHART_VNEXT_SKIP=1
export CLEAN=0
nix-shell ./scripts/python/shell.nix --run "./scripts/python/test.sh"
- name: Collect logs
if: ${{ failure() }}
run: |
nix-shell ./scripts/k8s/shell.nix --run "kubectl get pods -A -o wide"
nix-shell ./scripts/k8s/shell.nix --run "kubectl -n mayastor logs -l openebs.io/release=mayastor --all-containers=true"
nix-shell ./scripts/k8s/shell.nix --run "kubectl -n mayastor logs -l app=upgrade --all-containers=true"
- name: Upload pytest logs
if: always()
uses: actions/upload-artifact@v4
with:
name: pytest.log
path: pytest.log
- name: Report pytest results
if: always()
uses: pmeier/pytest-results-action@main
with:
path: report.xml
summary: true
display-options: a
fail-on-empty: true
title: Test results

k8s-ci-vm:
runs-on: ubuntu-latest
runs-on: ubuntu-latest-16-cores
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v11
Expand All @@ -61,8 +74,8 @@ jobs:
run: |
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
nix-shell ./scripts/k8s/shell.nix --run "echo"
nix-shell ./scripts/helm/shell.nix --run "echo"
- name: Test on VM
run: |
nix-shell ./scripts/k8s/shell.nix --run "cd chart; helm dependency update"
nix-shell ./scripts/helm/shell.nix --run "cd chart; helm dependency update"
nix-build ./tests/helm/test.nix --option sandbox false
10 changes: 8 additions & 2 deletions .github/workflows/release-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ jobs:
run: |
tag="${{ github.ref_name }}"
BASE_REF="${{ github.event.base_ref }}"
BRANCH="${BASE_REF#refs/heads/}"
if [ -n "$BASE_REF" ]; then
BRANCH="${BASE_REF#refs/heads/}"
else
BRANCH="$(nix-shell --pure --run "./scripts/helm/find-released-branch.sh "$tag"" ./scripts/helm/shell.nix)"
fi
echo "BASE_BRANCH=$BRANCH" >> $GITHUB_ENV
nix-shell --pure --run "./scripts/helm/publish-chart-yaml.sh --released "$tag" --released-branch "$BRANCH"" ./scripts/helm/shell.nix
nix-shell --pure --run "SKIP_GIT=1 ./scripts/helm/generate-readme.sh" ./scripts/helm/shell.nix
- name: Create Pull Request
Expand All @@ -73,7 +79,7 @@ jobs:
signoff: true
delete-branch: true
branch-suffix: "random"
base: ${{ github.event.base_ref }}
base: ${{ env.BASE_BRANCH }}
token: ${{ secrets.ORG_CI_GITHUB }}
- name: Approve Pull Request by CI Bot
if: ${{ steps.cpr.outputs.pull-request-number }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ __pycache__
# Pytest assets
/test-dir-*
tests/bdd/venv
pytest.log
pytest.log
#/tests/bdd/chart-vnext/
/chart/kubectl-plugin
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ repos:
pass_filenames: false
types: [file, rust]
language: system
- id: python-fmt
name: Python fmt
description: Run python fmt on files included in the commit.
entry: nix-shell --pure --run './scripts/python/fmt.sh'
pass_filenames: false
types: [file, python]
language: system
- id: commit-lint
name: Commit Lint
description: Runs commitlint against the commit message.
Expand Down
258 changes: 0 additions & 258 deletions Jenkinsfile

This file was deleted.

Loading

0 comments on commit 84ae388

Please sign in to comment.