Add ensure-rust role
Add a role to install Rust via the rustup tool. It defaults to installing globally, which avoids having to worry too much about setting paths for follow-on jobs. Packaged Rust and the upstream rustup install tool can live together, and there's various documentation about it. Thus I've made this such that we can expand it with packaged Rust support if there is a need, but I have not implemented that yet. Change-Id: I32f9b285904a7036f9a80ada8a49fa9cf31b5163
This commit is contained in:
parent
dab423acaf
commit
048aff6c98
@ -25,5 +25,6 @@ Roles
|
||||
launchpad-roles
|
||||
puppet-roles
|
||||
python-roles
|
||||
rust-roles
|
||||
system-roles
|
||||
translation-roles
|
||||
|
4
doc/source/rust-roles.rst
Normal file
4
doc/source/rust-roles.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Rust Roles
|
||||
==========
|
||||
|
||||
.. zuul:autorole:: ensure-rust
|
28
roles/ensure-rust/README.rst
Normal file
28
roles/ensure-rust/README.rst
Normal file
@ -0,0 +1,28 @@
|
||||
Install Rust
|
||||
|
||||
Install the Rust toolchain
|
||||
|
||||
**Role Variables**
|
||||
|
||||
.. zuul:rolevar:: ensure_rust_rustup
|
||||
:default: True
|
||||
|
||||
Install Rust via the ``rustup`` installer.
|
||||
|
||||
.. zuul:rolevar:: ensure_rust_rustup_toolchain
|
||||
:default: stable
|
||||
|
||||
The Rust toolchain to install with ``rustup``.
|
||||
|
||||
.. zuul:rolevar:: ensure_rust_rustup_path
|
||||
:default: /usr
|
||||
|
||||
Where to install Rust/Cargo with ``rustup``. ``/usr`` provides the
|
||||
tools globally. This may conflict with distribution Rust packages
|
||||
if installed.
|
||||
|
||||
.. zuul:rolevar:: ensure_rust_packages
|
||||
:default: False
|
||||
|
||||
Install Rust via system packages. This role does not currently
|
||||
support package install.
|
4
roles/ensure-rust/defaults/main.yaml
Normal file
4
roles/ensure-rust/defaults/main.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
ensure_rust_rustup: true
|
||||
ensure_rust_packages: false
|
||||
ensure_rust_rustup_toolchain: stable
|
||||
ensure_rust_rustup_path: /usr
|
8
roles/ensure-rust/tasks/main.yaml
Normal file
8
roles/ensure-rust/tasks/main.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
- name: Use rustup
|
||||
include_tasks: 'rustup.yaml'
|
||||
when: ensure_rust_rustup
|
||||
|
||||
- name: Install packages
|
||||
fail:
|
||||
msg: 'Packaged rust install not yet implemented'
|
||||
when: ensure_rust_packages
|
13
roles/ensure-rust/tasks/rustup.yaml
Normal file
13
roles/ensure-rust/tasks/rustup.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
- name: Install Rust
|
||||
shell: | # noqa 303
|
||||
set -o pipefail
|
||||
curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain {{ ensure_rust_rustup_toolchain }}
|
||||
environment:
|
||||
RUSTUP_HOME: '{{ ensure_rust_rustup_path }}'
|
||||
CARGO_HOME: '{{ ensure_rust_rustup_path }}'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
become: yes
|
||||
|
||||
- name: Use as selected Rust toolchain
|
||||
command: rustup default {{ ensure_rust_rustup_toolchain }}
|
21
test-playbooks/rust/ensure-rust.yaml
Normal file
21
test-playbooks/rust/ensure-rust.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
- hosts: all
|
||||
tasks:
|
||||
|
||||
- include_role:
|
||||
name: ensure-rust
|
||||
|
||||
- name: Test cargo run
|
||||
shell: |
|
||||
cargo new foo
|
||||
|
||||
- name: Copy hello world
|
||||
copy:
|
||||
src: hello.rs
|
||||
dest: hello.rs
|
||||
mode: 0644
|
||||
|
||||
- name: Compile hello world
|
||||
command: rustc hello.rs
|
||||
|
||||
- name: Run hello world
|
||||
command: ./hello
|
5
test-playbooks/rust/files/hello.rs
Normal file
5
test-playbooks/rust/files/hello.rs
Normal file
@ -0,0 +1,5 @@
|
||||
fn main() {
|
||||
|
||||
println!("Hello, World!");
|
||||
|
||||
}
|
140
zuul-tests.d/rust-jobs.yaml
Normal file
140
zuul-tests.d/rust-jobs.yaml
Normal file
@ -0,0 +1,140 @@
|
||||
- job:
|
||||
name: zuul-jobs-test-rust
|
||||
description: Test the rust roles
|
||||
tags: all-platforms
|
||||
run: test-playbooks/rust/ensure-rust.yaml
|
||||
files:
|
||||
- playbooks/ensure-rust.yaml
|
||||
- roles/ensure-rust
|
||||
- zuul.d/rust-jobs.yaml
|
||||
|
||||
# -* AUTOGENERATED *-
|
||||
# The following project section is autogenerated by
|
||||
# tox -e update-test-platforms
|
||||
# Please re-run to generate new job lists
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-rust-centos-7
|
||||
description: Test the rust roles on centos-7
|
||||
parent: zuul-jobs-test-rust
|
||||
tags: auto-generated
|
||||
nodeset:
|
||||
nodes:
|
||||
- name: centos-7
|
||||
label: centos-7
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-rust-centos-8
|
||||
description: Test the rust roles on centos-8
|
||||
parent: zuul-jobs-test-rust
|
||||
tags: auto-generated
|
||||
nodeset:
|
||||
nodes:
|
||||
- name: centos-8
|
||||
label: centos-8
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-rust-debian-stretch
|
||||
description: Test the rust roles on debian-stretch
|
||||
parent: zuul-jobs-test-rust
|
||||
tags: auto-generated
|
||||
nodeset:
|
||||
nodes:
|
||||
- name: debian-stretch
|
||||
label: debian-stretch
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-rust-fedora-31
|
||||
description: Test the rust roles on fedora-31
|
||||
parent: zuul-jobs-test-rust
|
||||
tags: auto-generated
|
||||
nodeset:
|
||||
nodes:
|
||||
- name: fedora-31
|
||||
label: fedora-31
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-rust-gentoo-17-0-systemd
|
||||
description: Test the rust roles on gentoo-17-0-systemd
|
||||
parent: zuul-jobs-test-rust
|
||||
tags: auto-generated
|
||||
nodeset:
|
||||
nodes:
|
||||
- name: gentoo-17-0-systemd
|
||||
label: gentoo-17-0-systemd
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-rust-opensuse-15
|
||||
description: Test the rust roles on opensuse-15
|
||||
parent: zuul-jobs-test-rust
|
||||
tags: auto-generated
|
||||
nodeset:
|
||||
nodes:
|
||||
- name: opensuse-15
|
||||
label: opensuse-15
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-rust-opensuse-tumbleweed-nv
|
||||
voting: false
|
||||
description: Test the rust roles on opensuse-tumbleweed
|
||||
parent: zuul-jobs-test-rust
|
||||
tags: auto-generated
|
||||
nodeset:
|
||||
nodes:
|
||||
- name: opensuse-tumbleweed
|
||||
label: opensuse-tumbleweed
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-rust-ubuntu-bionic
|
||||
description: Test the rust roles on ubuntu-bionic
|
||||
parent: zuul-jobs-test-rust
|
||||
tags: auto-generated
|
||||
nodeset:
|
||||
nodes:
|
||||
- name: ubuntu-bionic
|
||||
label: ubuntu-bionic
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-rust-ubuntu-xenial
|
||||
description: Test the rust roles on ubuntu-xenial
|
||||
parent: zuul-jobs-test-rust
|
||||
tags: auto-generated
|
||||
nodeset:
|
||||
nodes:
|
||||
- name: ubuntu-xenial
|
||||
label: ubuntu-xenial
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-rust-ubuntu-focal
|
||||
description: Test the rust roles on ubuntu-focal
|
||||
parent: zuul-jobs-test-rust
|
||||
tags: auto-generated
|
||||
nodeset:
|
||||
nodes:
|
||||
- name: ubuntu-focal
|
||||
label: ubuntu-focal
|
||||
|
||||
- project:
|
||||
check:
|
||||
jobs:
|
||||
- zuul-jobs-test-rust-centos-7
|
||||
- zuul-jobs-test-rust-centos-8
|
||||
- zuul-jobs-test-rust-debian-stretch
|
||||
- zuul-jobs-test-rust-fedora-31
|
||||
- zuul-jobs-test-rust-gentoo-17-0-systemd
|
||||
- zuul-jobs-test-rust-opensuse-15
|
||||
- zuul-jobs-test-rust-opensuse-tumbleweed-nv
|
||||
- zuul-jobs-test-rust-ubuntu-bionic
|
||||
- zuul-jobs-test-rust-ubuntu-xenial
|
||||
- zuul-jobs-test-rust-ubuntu-focal
|
||||
gate:
|
||||
jobs:
|
||||
- zuul-jobs-test-rust-centos-7
|
||||
- zuul-jobs-test-rust-centos-8
|
||||
- zuul-jobs-test-rust-debian-stretch
|
||||
- zuul-jobs-test-rust-fedora-31
|
||||
- zuul-jobs-test-rust-gentoo-17-0-systemd
|
||||
- zuul-jobs-test-rust-opensuse-15
|
||||
- zuul-jobs-test-rust-ubuntu-bionic
|
||||
- zuul-jobs-test-rust-ubuntu-xenial
|
||||
- zuul-jobs-test-rust-ubuntu-focal
|
Loading…
Reference in New Issue
Block a user