Skip to content

Rethink tests

Rethink tests #74

Workflow file for this run

---
name: Test
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
get-chart:
runs-on: ubuntu-latest
outputs:
changed_charts: ${{ steps.get-chart.outputs.changed_charts }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: charts
fetch-depth: 2 # to be able to obtain files changed in the latest commit
- id: get-chart
name: "Get modified charts"
run: |
cd charts
files_changed="$(git diff --name-only HEAD^ HEAD)"
# Adding || true to avoid "Process exited with code 1" errors
charts_dirs_changed="$(echo "$files_changed" | xargs dirname | grep -o "charts/[^/]*" | sed "s|charts/||g" | uniq | tr '\n' ' ' || true)"
echo "changed:${charts_dirs_changed}"
echo "::set-output name=changed_charts::${charts_dirs_changed}"
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v3
with:
python-version: 3.7
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.9.4
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --chart-dirs helm --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --validate-maintainers=false --target-branch main
test-values:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run the test
run: |
cd charts/db-operator
./scripts/test_values -p ./ci/unit-test
db-operator-test:
runs-on: ubuntu-latest
needs: get-chart
if: ${{ contains(needs.get-chart.outputs.changed_charts, 'db-operator') || contains(needs.get-chart.outputs.changed_charts, 'db-instances') }}
strategy:
matrix:
k8s_version:
[
"v1.22.8",
"v1.23.5",
"v1.24.16",
"v1.25.12",
"v1.26.7",
"v1.27.4",
]
steps:
- name: Checkout
uses: actions/checkout@v3
# The existing apparmor profile for mysql needs to be removed.
# https://github.com/actions/virtual-environments/issues/181
# https://github.com/moby/moby/issues/7512#issuecomment-51845976
- name: Remove MySQL App Armour Configuration
run: |
set -x
sudo apt-get remove mysql-server --purge
sudo apt-get update -y
sudo apt-get install apparmor-profiles
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
- name: Create k3d cluster
env:
K8S_VERSION: ${{ matrix.k8s_version }}
run: make k3d
- name: Install Cert Manager
run: make cert-manager
- name: Install Helm chart
run: make db-operator
- name: Integration test
run: ./tests/db-operator/integration.sh