Tools like Travis can be really helpful to figure it out the stability of our software, specially when we have a huge codebase that requires a lot of time to compile and test.
In this post I'll show how to integrate the Travis CI for our project, because it's open source we can use the Travis free account.
We need to perform a couple of things, first we need to enable our project for Travis CI in the repositories page. Then we add a .travis.yml
file in the root with the next configuration:
.travis.yml
language: rust
rust:
- stable
- beta
- nightly
matrix:
allow_failures:
- rust: nightly
fast_finish: true
cache: cargo
services:
- postgresql
addons:
postgresql: "10"
apt:
packages:
- postgresql-10
- postgresql-client-10
env:
global:
- PGPORT: 5433
before_script:
- sudo sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/*/main/pg_hba.conf
- sudo service postgresql restart
- sleep 1
- sudo apt-get update
- sudo apt-get install -y postgresql-10-rum
- psql -c 'create database mystore_test;' -U postgres
- psql -c 'CREATE EXTENSION rum;' -d mystore_test -U postgres
script:
- cargo install diesel_cli --quiet || true
- cargo build --verbose --all
- DATABASE_URL=postgres://postgres:@localhost/mystore_test diesel setup
- cargo test --verbose --all
Although we are targeting stable, we might want to test it against all the compiler targets and see if our code does not break some new functionality.
We enable postgres v10 and write the scripts we're gonna need previous the test.
One last thing is add badge to the README, so people can see if our software is stable.
README.md
:
# practical-rust-web
[![Build Status](https://travis-ci.org/practical-rust-web-development/mystore.svg?branch=master)](https://travis-ci.org/practical-rust-web-development/mystore)
You can take a look at the source code here
Top comments (12)
Hello. I do this and got all data. but i only need only username and title. How to do this.Thank you.
[derive(Serialize, Deserialize)]
pub struct UserRoleList(pub Vec<(Role, User)>);
impl UserRoleList {
pub fn list(connection: &PgConnection) -> Self {
use crate::schema::{roles,users};
use diesel::RunQueryDsl;
use diesel::QueryDsl;
}
Hi, like SQL you can use a select clause, for example: github.com/practical-rust-web-deve...
thank you
hello teacher.i have user table and role table.
select fullname, roles.title from users inner join roles on roles.id = users.role_id;
how to write this in rust.
thank you.
Probably you need this diesel.rs
thank you, but i'm so beginner i still don't understand.
Do you know Rust?
know but not much.
Check out include_sql. Diesel is a full featured ORM. Not all projects need it, you can of course write SQL directly.
thank you.
Hi, you need to register an user, for example:
Then you need to login:
You copy the cookie and csrf token and pass them through the request: