Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test tox installation on pre-installed python #81

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 66 additions & 8 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,61 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: woke
uses: canonical-web-and-design/inclusive-naming@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
fail-on-error: true

charmcraft:
runs-on: ubuntu-latest
outputs:
channel: ${{ steps.charmcraft.outputs.channel }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Load charmcraft channel
id: charmcraft
run: echo "channel=$(cat tests/.charmcraft-channel)" >> $GITHUB_OUTPUT

test-python-pre-installed:
name: Test pre-installed-python environment
runs-on: ubuntu-latest
needs: [charmcraft]
strategy:
matrix:
python:
- '3.8'
- '3.10'
- '3.12'
tox:
- '4.18.0'
- ''
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Check out code
uses: actions/checkout@v4
- uses: ./
with:
provider: lxd
channel: latest/stable
juju-channel: 3/stable
tox-version: ${{ matrix.tox }}
charmcraft-channel: ${{ needs.charmcraft.outputs.channel }}
- name: Run Tests
run: |
tox -e tests -- -k "not k8s"
exit $?


test-lxd:
name: Test lxd environment
needs: [charmcraft]
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -34,12 +79,13 @@ jobs:
- '3.5/edge'
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: ./
with:
provider: lxd
channel: latest/stable
juju-channel: ${{ matrix.juju }}
charmcraft-channel: ${{ needs.charmcraft.outputs.channel }}

- name: Run Tests for != 2.x
if : ${{ startsWith(matrix.juju, 2) != true }}
Expand All @@ -55,6 +101,7 @@ jobs:

test-microk8s-strict:
name: Test microk8s strict
needs: [charmcraft]
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -66,18 +113,20 @@ jobs:
- 1.27-strict/stable
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: ./
with:
provider: microk8s
channel: ${{ matrix.channel }}
charmcraft-channel: ${{ needs.charmcraft.outputs.channel }}

- name: Run Tests
run: |
tox -e tests -- -k "not machine"

test-microk8s-classic:
name: Test microk8s classic
needs: [charmcraft]
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -89,66 +138,74 @@ jobs:
- latest/stable
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: ./
with:
provider: microk8s
channel: ${{ matrix.channel }}
juju-channel: 2.9/stable
charmcraft-channel: ${{ needs.charmcraft.outputs.channel }}

- name: Run Tests
run: |
tox -e 2.9-tests -- -k "not machine"

test-microk8s-default-addons:
name: Test default addons are enabled by microk8s provider.
needs: [charmcraft]
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: ./
with:
provider: microk8s
channel: 1.28-strict/stable
charmcraft-channel: ${{ needs.charmcraft.outputs.channel }}

- name: Run Tests
run: |
tox -e tests -- -k "addons" --addons "storage dns rbac"

test-microstack:
runs-on: self-hosted
needs: [charmcraft]
name: Test microstack environment
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: ./
with:
provider: microstack
charmcraft-channel: ${{ needs.charmcraft.outputs.channel }}

- name: Run Tests
run: |
tox -e tests -- -k "not k8s"

test-vSphere:
runs-on: self-hosted
needs: [charmcraft]
name: Test vSphere environment
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: ./
with:
provider: vsphere
credentials-yaml: ${{ secrets.CREDENTIALS_YAML }}
clouds-yaml: ${{ secrets.CLOUDS_YAML }}
bootstrap-options: "--model-default datastore=vsanDatastore --model-default primary-network=VLAN_2764 --bootstrap-image=juju-ci-root/templates/jammy-test-template --bootstrap-series=jammy"
bootstrap-constraints: "arch=amd64 cores=2 mem=4G"
charmcraft-channel: ${{ needs.charmcraft.outputs.channel }}

- name: Run Tests
run: |
tox -e tests -- -k "not k8s"

test-multi-controller:
name: Test microk8s next to lxd
needs: [charmcraft]
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -157,12 +214,13 @@ jobs:
- ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup k8s controller
uses: ./
with:
provider: microk8s
channel: 1.28-strict/stable
charmcraft-channel: ${{ needs.charmcraft.outputs.channel }}
- name: Save k8s controller name
id: k8s-controller
# The `CONTROLLER_NAME` envvar is set by this actions
Expand Down
4 changes: 4 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ inputs:
description: "microk8s addons to enable"
required: false
default: "storage dns rbac"
tox-version:
description: "Version of tox to install"
required: false
default: ""
container-registry-url:
description: "Container registry to use"
runs:
Expand Down
28 changes: 25 additions & 3 deletions dist/bootstrap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5671,6 +5671,29 @@ function fixed_revision_args(app, channel, arch) {
}
return `--channel=${channel}`;
}
function install_tox(tox_version = "") {
return __awaiter(this, void 0, void 0, function* () {
// Install tox if it's not already installed
const hasTox = yield exec.exec("which tox", [], ignoreFail);
if (hasTox == 0) {
core.info("tox is already installed");
exec.exec("tox --version");
return;
}
const hasPip = yield exec.exec("which pip", [], ignoreFail);
const version = tox_version ? `==${tox_version}` : "";
if (hasPip == 0) {
core.info(`pip is available, install tox${version}`);
yield exec.exec(`pip install tox${version}`);
}
else {
core.info("Neither tox nor pip are available, install python3-pip via apt, then tox");
yield apt_get("update -yqq");
yield apt_get("install -yqq python3-pip");
yield exec.exec(`sudo --preserve-env=http_proxy,https_proxy,no_proxy pip3 install tox${version}`);
}
});
}
function run() {
return __awaiter(this, void 0, void 0, function* () {
const HOME = process.env["HOME"];
Expand All @@ -5687,6 +5710,7 @@ function run() {
const juju_channel = core.getInput("juju-channel");
const juju_bundle_channel = core.getInput("juju-bundle-channel");
const juju_crashdump_channel = core.getInput("juju-crashdump-channel");
const tox_version = core.getInput("tox-version");
const lxd_channel = (provider === "lxd" && channel) ? channel : core.getInput("lxd-channel");
const microk8s_group = get_microk8s_group();
let bootstrap_constraints = core.getInput("bootstrap-constraints");
Expand Down Expand Up @@ -5717,9 +5741,7 @@ function run() {
yield exec.exec('bash', ['-c', 'sudo usermod -a -G lxd $USER']);
core.endGroup();
core.startGroup("Install tox");
yield apt_get("update -yqq");
yield apt_get("install -yqq python3-pip");
yield exec.exec("sudo --preserve-env=http_proxy,https_proxy,no_proxy pip3 install tox");
yield install_tox(tox_version);
core.endGroup();
core.startGroup("Install Juju");
yield snap_install("juju", juju_channel, juju_channel.includes("2.9"));
Expand Down
28 changes: 25 additions & 3 deletions src/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,29 @@ function fixed_revision_args(app:string, channel:string, arch:string): string{
return `--channel=${channel}`
}


async function install_tox(tox_version: string = "") {
// Install tox if it's not already installed
const hasTox = await exec.exec("which tox", [], ignoreFail);
if (hasTox == 0) {
core.info("tox is already installed");
exec.exec("tox --version");
return;
}
const hasPip = await exec.exec("which pip", [], ignoreFail);
const version = tox_version ? `==${tox_version}` : "";
if (hasPip == 0) {
core.info(`pip is available, install tox${version}`);
await exec.exec(`pip install tox${version}`);
} else {
core.info("Neither tox nor pip are available, install python3-pip via apt, then tox");
await apt_get("update -yqq");
await apt_get("install -yqq python3-pip");
await exec.exec(`sudo --preserve-env=http_proxy,https_proxy,no_proxy pip3 install tox${version}`);
}
}


async function run() {
const HOME = process.env["HOME"]
const GITHUB_SHA = process.env["GITHUB_SHA"].slice(0, 5)
Expand All @@ -208,6 +231,7 @@ async function run() {
const juju_channel = core.getInput("juju-channel");
const juju_bundle_channel = core.getInput("juju-bundle-channel");
const juju_crashdump_channel = core.getInput("juju-crashdump-channel")
const tox_version = core.getInput("tox-version");

const lxd_channel = (provider === "lxd" && channel) ? channel : core.getInput("lxd-channel");

Expand Down Expand Up @@ -240,9 +264,7 @@ async function run() {
await exec.exec('bash', ['-c', 'sudo usermod -a -G lxd $USER']);
core.endGroup();
core.startGroup("Install tox");
await apt_get("update -yqq");
await apt_get("install -yqq python3-pip");
await exec.exec("sudo --preserve-env=http_proxy,https_proxy,no_proxy pip3 install tox");
await install_tox(tox_version);
core.endGroup();
core.startGroup("Install Juju");
await snap_install("juju", juju_channel, juju_channel.includes("2.9"));
Expand Down
1 change: 1 addition & 0 deletions tests/.charmcraft-channel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.x/stable
Loading