Skip to content

cache: Remove one 0 from hash name check to cache more URLs #728

cache: Remove one 0 from hash name check to cache more URLs

cache: Remove one 0 from hash name check to cache more URLs #728

Workflow file for this run

name: test
"on":
pull_request:
branches: [main]
workflow_call:
secrets:
GCLOUD_PROJECT:
required: true
GCLOUD_SA_KEY:
required: true
repository_dispatch:
types: [test]
env:
KCIDB_IO_URL: kcidb-io@git+https://github.com/kernelci/kcidb-io.git@${{ github.event.client_payload.kcidb_io_ref || 'main' }}
jobs:
check_python:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.9", "3.10"]
runs-on: [ubuntu-latest]
include:
- python-version: "3.6"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Check setup.py and requirements.txt are consistent
run: |
# Check both install_requires in setup.py and requirements.txt contain
# the same dependencies
(
set -e -u -o pipefail
unique_requires=$({
sed -n '/install_requires=/,/],/ s/.*"\([^"]\+\)".*/\1/p' setup.py |
sort -u
grep -v '^#' requirements.txt |
sort -u
} | sort | uniq -u)
if [ -n "$unique_requires" ]; then
echo "Requirements not both in setup.py and requirements.txt:" >&2
echo "$unique_requires" >&2
false
fi
)
- name: Install
run: |
python -m pip install --upgrade pip setuptools
sed -i -e "s|kcidb-io@[^\"]*|${KCIDB_IO_URL}|" requirements.txt setup.py
pip3 install --upgrade '.[dev]'
- name: Check python sources with flake8
run: "flake8 kcidb *.py"
env:
KCIDB_HOOKS: "pre-commit"
- name: Check python sources with pylint
run: "pylint kcidb *.py"
env:
KCIDB_HOOKS: "pre-commit"
- name: Test with pytest
run: KCIDB_IO_HEAVY_ASSERTS=1 KCIDB_HEAVY_ASSERTS=1 pytest --tb=native
env:
KCIDB_HOOKS: "pre-commit"
check_auxiliary_files:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install
run: |
python -m pip install --upgrade pip setuptools
sed -i -e "s|kcidb-io@[^\"]*|${KCIDB_IO_URL}|" requirements.txt setup.py
pip3 install --upgrade '.[dev]'
- name: Check YAML files with yamllint
run: find -name '*.yaml' -or -name '*.yml' | xargs yamllint
env:
KCIDB_HOOKS: "pre-commit"
- name: Check test catalog is ordered alphabetically
run: |
test_list=$(
python3 <(
echo "import sys, yaml"
echo "for k in yaml.safe_load(sys.stdin).keys():"
echo " print(k)"
) < tests.yaml
)
export LANG=C
test_list_diff=$(diff -u <(echo "$test_list") \
<(echo "$test_list" | sort)) ||
{
echo "Tests out of alphabetic order." >&2
echo "Change the order as below:" >&2
echo "$test_list_diff" >&2
false
}
env:
KCIDB_HOOKS: "pre-commit"
- name: Validate test catalog
run: kcidb-tests-validate --urls < tests.yaml
check_deployment:
needs: check_python
runs-on: ubuntu-latest
environment: staging
steps:
- name: Check credentials
env:
GCLOUD_PROJECT: ${{ secrets.GCLOUD_PROJECT }}
GCLOUD_SA_KEY: ${{ secrets.GCLOUD_SA_KEY }}
run: |
# Check credentials
CREDENTIALS_PRESENT=true
function check() {
if eval "test -z \"\$$1\""; then
echo "$1 secret is missing." >&2
CREDENTIALS_PRESENT=false
fi
}
check GCLOUD_PROJECT
check GCLOUD_SA_KEY
if "$CREDENTIALS_PRESENT"; then
echo "All required credentials are present, continuing." >&2
else
echo "Required credentials are missing, aborting." >&2
fi
"$CREDENTIALS_PRESENT"
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install
run: |
python -m pip install --upgrade pip setuptools
sed -i -e "s|kcidb-io@[^\"]*|${KCIDB_IO_URL}|" requirements.txt setup.py
pip3 install --upgrade '.[dev]'
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v1
with:
project_id: ${{ secrets.GCLOUD_PROJECT }}
credentials_json: ${{ secrets.GCLOUD_SA_KEY }}
create_credentials_file: true
export_environment_variables: true
- name: Setup Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Deploy, Test, and Withdraw
run: |
status=0
declare -a args=(
"kernelci-staging" "gh_run_${{ github.run_id }}" "1"
--smtp-mocked --test
)
declare -a env_args=(
"${args[@]}" --heavy-asserts --log-level=DEBUG
)
./cloud deploy "${env_args[@]}" --verbose &&
KCIDB_DEPLOYMENT="This deployment is empty" \
./cloud shell "${env_args[@]}" -- \
pytest --tb=native --verbosity=2 --log-level=DEBUG ||
status=$((status || $?))
./cloud withdraw "${args[@]}" --verbose || status=$((status || $?))
exit "$status"