Skip to content

Commit

Permalink
Merge pull request #163 from hmlanigan/move-test-deploy-test-deploy-r…
Browse files Browse the repository at this point in the history
…evision-aws-to-gating

Move test deploy test deploy revision aws to gating
  • Loading branch information
hmlanigan authored Nov 17, 2023
2 parents b613e46 + 3352855 commit 0b6a360
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 87 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ensure-venv:

.PHONY: install-deps
install-deps: ensure-venv
$(virtualenv_dir)/bin/pip3 install -r requirements.txt
PIP_CONSTRAINTS=./constraints.txt $(virtualenv_dir)/bin/pip3 install -r requirements.txt
# The postbuildscript plugin version is "3.1.0-375.v3db_cd92485e1" which cannot be parsed.
# So we override to set it to "3.1.0".
# jenkins-job-builder only cares if the plugin version is > 2.
Expand Down
3 changes: 3 additions & 0 deletions constraint.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Required to fix "AttributeError: cython_sources" from
# setuptools package. Seen with 68.2.2 setuptools as well.
cython<3
3 changes: 2 additions & 1 deletion jobs/ci-run/integration/gen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
up waiting for manual wire up to the integration runner.

None of the files inside the gen folder should be modified by hand and instead
should be changed in the template file within the tool.
should be changed in the template file within the tool. Use `make gen-wire-tests`
at the top level to generate the files.
2 changes: 0 additions & 2 deletions jobs/ci-run/integration/gen/test-deploy-unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@
current-parameters: true
- name: 'test-deploy-test-deploy-os-aws'
current-parameters: true
- name: 'test-deploy-test-deploy-revision-aws'
current-parameters: true
2 changes: 2 additions & 0 deletions jobs/ci-run/integration/gen/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
current-parameters: true
- name: 'test-deploy-test-deploy-os-lxd'
current-parameters: true
- name: 'test-deploy-test-deploy-revision-aws'
current-parameters: true
- name: 'test-deploy-test-deploy-revision-lxd'
current-parameters: true

Expand Down
163 changes: 84 additions & 79 deletions tests/suites/static_analysis/lint_yaml.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
yaml_check() {
FILE="${1}"
FILE="${1}"

py=$(cat <<EOF
py=$(
cat <<EOF
import yaml, sys
def path(loader, tag_suffix, node):
Expand All @@ -13,25 +14,26 @@ def path(loader, tag_suffix, node):
yaml.add_multi_constructor('', path)
yaml.load(sys.stdin, Loader=yaml.Loader)
EOF
)

OUT=$(python3 -c "${py}" 2>&1 < "${FILE}" || true)
if [ -n "${OUT}" ]; then
echo ""
echo "$(red 'Found some issues:')"
echo "${OUT}"
exit 1
fi
)

OUT=$(python3 -c "${py}" 2>&1 <"${FILE}" || true)
if [ -n "${OUT}" ]; then
echo ""
echo "$(red 'Found some issues:')"
echo "${OUT}"
exit 1
fi
}

run_yaml_check() {
FILES="${2}"
FILES="${2}"

echo "$FILES" | while IFS= read -r line; do yaml_check "${line}"; done
echo "$FILES" | while IFS= read -r line; do yaml_check "${line}"; done
}

run_yaml_deadcode() {
OUT=$(go run tests/suites/static_analysis/deadcode/main.go "$(pwd)" <<EOF 2>&1 || true
OUT=$(
go run tests/suites/static_analysis/deadcode/main.go "$(pwd)" <<EOF 2>&1 || true
files:
skip:
- .github/workflows/static-analysis.yml
Expand Down Expand Up @@ -91,18 +93,20 @@ jobs:
- lxd-src-command-focal-base
- nw-deploy-focal-amd64-lxd
- nw-deploy-jammy-amd64-lxd
- test-controllercharm-multijob
EOF
)
if [ -n "${OUT}" ]; then
echo ""
echo "$(red 'Found some issues:')"
echo "${OUT}"
exit 1
fi
)
if [ -n "${OUT}" ]; then
echo ""
echo "$(red 'Found some issues:')"
echo "${OUT}"
exit 1
fi
}

run_yaml_simplify() {
OUT=$(go run tests/suites/static_analysis/simplify/main.go "$(pwd)" <<EOF 2>&1 || true
OUT=$(
go run tests/suites/static_analysis/simplify/main.go "$(pwd)" <<EOF 2>&1 || true
files:
skip:
- .github/workflows/static-analysis.yml
Expand Down Expand Up @@ -132,75 +136,76 @@ jobs:
- test-secrets_k8s-multijob:IntegrationTests-secrets_k8s
- test-secrets_iaas-multijob:IntegrationTests-secrets_iaas
EOF
)
if [ -n "${OUT}" ]; then
echo ""
echo "$(red 'Found some issues:')"
echo "${OUT}"
exit 1
fi
)
if [ -n "${OUT}" ]; then
echo ""
echo "$(red 'Found some issues:')"
echo "${OUT}"
exit 1
fi
}

run_yaml_alphabetise() {
OUT=$(go run tests/suites/static_analysis/alphabetise/main.go "$(pwd)" <<EOF 2>&1 || true
OUT=$(
go run tests/suites/static_analysis/alphabetise/main.go "$(pwd)" <<EOF 2>&1 || true
files:
skip:
- .github/workflows/static-analysis.yml
- .github/workflows/local-deployment.yml
jobs:
ignore: []
EOF
)
if [ -n "${OUT}" ]; then
echo ""
echo "$(red 'Found some issues:')"
echo "${OUT}"
exit 1
fi
)
if [ -n "${OUT}" ]; then
echo ""
echo "$(red 'Found some issues:')"
echo "${OUT}"
exit 1
fi

}

test_static_analysis_yaml() {
if [ "$(skip 'test_static_analysis_yaml')" ]; then
echo "==> TEST SKIPPED: static yaml analysis"
return
fi

(
set_verbosity

cd .. || exit

FILES=$(find ./* -name '*.yml')

go mod download

# YAML static analysis
if which python >/dev/null 2>&1; then
run "run_yaml_check" "${FILES}"
else
echo "python not found, yaml static analysis disabled"
fi

# YAML deadcode elimiation
if which go >/dev/null 2>&1; then
run "run_yaml_deadcode"
else
echo "go not found, yaml deadcode disabled"
fi

# YAML simplify
if which go >/dev/null 2>&1; then
run "run_yaml_simplify"
else
echo "go not found, yaml simplify disabled"
fi

# YAML alphabetise
if which go >/dev/null 2>&1; then
run "run_yaml_alphabetise"
else
echo "go not found, yaml alphabetise disabled"
fi
)
if [ "$(skip 'test_static_analysis_yaml')" ]; then
echo "==> TEST SKIPPED: static yaml analysis"
return
fi

(
set_verbosity

cd .. || exit

FILES=$(find ./* -name '*.yml')

go mod download

# YAML static analysis
if which python >/dev/null 2>&1; then
run "run_yaml_check" "${FILES}"
else
echo "python not found, yaml static analysis disabled"
fi

# YAML deadcode elimiation
if which go >/dev/null 2>&1; then
run "run_yaml_deadcode"
else
echo "go not found, yaml deadcode disabled"
fi

# YAML simplify
if which go >/dev/null 2>&1; then
run "run_yaml_simplify"
else
echo "go not found, yaml simplify disabled"
fi

# YAML alphabetise
if which go >/dev/null 2>&1; then
run "run_yaml_alphabetise"
else
echo "go not found, yaml alphabetise disabled"
fi
)
}
13 changes: 10 additions & 3 deletions tools/gen-wire-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ You also need to provide a configuration file (usually `juju.config`) via stdin.

We suggest running it as follows:

```bash
cd ..
make gen-wire-tests
```

To run by hand, or the hard way:

```bash
cd tools/gen-wire-tests
cat juju.config | go run main.go <jujuroot>/tests/suites \
../../jobs/ci-run/integration/gen
../../jobs/ci-run/integration/gen <version of juju>
```

or
Expand All @@ -21,10 +28,10 @@ or
cd tools/gen-wire-tests
go build main.go
cat juju.config | ./main <jujuroot>/tests/suites \
../../jobs/ci-run/integration/gen
../../jobs/ci-run/integration/gen <version of juju>
```

where `<jujuroot>` is the path to the Juju source tree on your local machine.

If you are adding new test suites, you will also need to add a new job to
`jobs/ci-run/integration/integrationtests.yml`.
`jobs/ci-run/integration/integrationtests.yml`.
1 change: 0 additions & 1 deletion tools/gen-wire-tests/juju.config
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ folders:
- test_deploy_charms
aws:
- test_deploy_os
- test_deploy_revision
model:
lxd:
- test_model_multi
Expand Down

0 comments on commit 0b6a360

Please sign in to comment.