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

Try out M1 Runners #3923

Merged
merged 5 commits into from
Feb 4, 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
4 changes: 2 additions & 2 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/audit-check@v1
- uses: actions/checkout@v4
- uses: actions-rust-lang/audit@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/benches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
backend: ["postgres", "sqlite", "mysql"]
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install postgres (Linux)
if: matrix.backend == 'postgres'
Expand Down
66 changes: 37 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ jobs:
matrix:
rust: ["stable", "beta", "nightly"]
backend: ["postgres", "sqlite", "mysql"]
os: [ubuntu-latest, macos-latest, windows-2019]
os: [ubuntu-latest, macos-latest, macos-14, windows-2019]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache cargo registry
uses: actions/cache@v3
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-${{ matrix.backend }}-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Set environment variables
Expand Down Expand Up @@ -121,14 +118,23 @@ jobs:
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://root:root@localhost/diesel_unit_test" >> $GITHUB_ENV

- name: Install postgres (MacOS)
if: runner.os == 'macOS' && matrix.backend == 'postgres'
if: matrix.os == 'macos-latest' && matrix.backend == 'postgres'
run: |
initdb -D /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres start
sleep 3
createuser -s postgres
echo "PG_DATABASE_URL=postgres://postgres@localhost/" >> $GITHUB_ENV
echo "PG_EXAMPLE_DATABASE_URL=postgres://postgres@localhost/diesel_example" >> $GITHUB_ENV
- name: Install postgres (MacOS M1)
if: matrix.os == 'macos-14' && matrix.backend == 'postgres'
run: |
brew install postgresql
brew services start postgresql@14
sleep 3
createuser -s postgres
echo "PG_DATABASE_URL=postgres://postgres@localhost/" >> $GITHUB_ENV
echo "PG_EXAMPLE_DATABASE_URL=postgres://postgres@localhost/diesel_example" >> $GITHUB_ENV

- name: Install sqlite (MacOS)
if: runner.os == 'macOS' && matrix.backend == 'sqlite'
Expand All @@ -137,7 +143,7 @@ jobs:
echo "SQLITE_DATABASE_URL=/tmp/test.db" >> $GITHUB_ENV

- name: Install mysql (MacOS)
if: runner.os == 'macOS' && matrix.backend == 'mysql'
if: matrix.os == 'macos-latest' && matrix.backend == 'mysql'
run: |
brew install [email protected]
/usr/local/opt/[email protected]/bin/mysql_install_db
Expand All @@ -149,6 +155,20 @@ jobs:
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://runner@localhost/diesel_unit_test" >> $GITHUB_ENV
echo "MYSQLCLIENT_LIB_DIR=/usr/local/opt/[email protected]/lib" >> $GITHUB_ENV

- name: Install mysql (MacOS M1)
if: matrix.os == 'macos-14' && matrix.backend == 'mysql'
run: |
brew install [email protected]
ls /opt/homebrew/opt/[email protected]
/opt/homebrew/opt/[email protected]/bin/mysql_install_db
/opt/homebrew/opt/[email protected]/bin/mysql.server start
sleep 3
/opt/homebrew/opt/[email protected]/bin/mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'runner'@'localhost';" -urunner
echo "MYSQL_DATABASE_URL=mysql://runner@localhost/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://runner@localhost/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://runner@localhost/diesel_unit_test" >> $GITHUB_ENV
echo "MYSQLCLIENT_LIB_DIR=/opt/homebrew/opt/[email protected]/lib" >> $GITHUB_ENV

- name: Install sqlite (Windows)
if: runner.os == 'Windows' && matrix.backend == 'sqlite'
shell: cmd
Expand Down Expand Up @@ -300,16 +320,13 @@ jobs:
name: Compiletests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2023-09-21
- name: Cache cargo registry
uses: actions/cache@v3
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: compile_test-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Install dependencies
Expand All @@ -325,16 +342,13 @@ jobs:
name: Check rustfmt style && run clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Cache cargo registry
uses: actions/cache@v3
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: clippy-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Install dependencies
Expand Down Expand Up @@ -405,16 +419,13 @@ jobs:
name: Check sqlite bundled + Sqlite with asan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: "rust-src"
- name: Cache cargo registry
uses: actions/cache@v3
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: sqlite_bundled-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Test diesel-cli
Expand All @@ -437,17 +448,14 @@ jobs:
name: Check Minimal supported rust version (1.70.0)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/[email protected]
- uses: dtolnay/rust-toolchain@nightly
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@cargo-minimal-versions
- name: Cache cargo registry
uses: actions/cache@v3
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: minimal_rust_version-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Install dependencies
run: |
Expand All @@ -471,7 +479,7 @@ jobs:

steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check the spelling of the files in our repo
uses: crate-ci/typos@master
7 changes: 2 additions & 5 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Cache cargo registry
uses: actions/cache@v3
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-doc-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Get the branch name
id: current_branch
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ jobs:
backend: ["postgres", "sqlite", "mysql"]
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: cache
uses: actions/cache@v3
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
diesel_bench/target
key: metrics-${{matrix.backend}}-cargo-${{ hashFiles('diesel_bench/Cargo.toml')}}

- name: Install postgres (Linux)
Expand Down
1 change: 1 addition & 0 deletions diesel_tests/tests/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn selecting_basic_data() {
user_alias.field(users::name),
user_alias.field(users::hair_color),
))
.order(user_alias.field(users::name))
.load(connection)
.unwrap();

Expand Down
13 changes: 10 additions & 3 deletions diesel_tests/tests/boxed_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn boxed_queries_can_differ_conditionally() {
}

let source = |query| match query {
Query::All => users::table.into_boxed(),
Query::All => users::table.order(users::name.desc()).into_boxed(),
Query::Ordered => users::table.order(users::name.desc()).into_boxed(),
Query::One => users::table
.filter(users::name.ne("jim"))
Expand All @@ -51,7 +51,7 @@ fn boxed_queries_can_differ_conditionally() {
let jim = find_user_by_name("Jim", connection);

let all = source(Query::All).load(connection);
let expected_data = vec![sean.clone(), tess.clone(), jim.clone()];
let expected_data = vec![tess.clone(), sean.clone(), jim.clone()];
assert_eq!(Ok(expected_data), all);

let ordered = source(Query::Ordered).load(connection);
Expand All @@ -69,6 +69,7 @@ fn boxed_queries_implement_select_dsl() {
let data = users::table
.into_boxed()
.select(users::name)
.order(users::name)
.load::<String>(connection);
assert_eq!(Ok(vec!["Sean".into(), "Tess".into()]), data);
}
Expand All @@ -92,7 +93,11 @@ fn boxed_queries_implement_filter_dsl() {
#[test]
fn boxed_queries_implement_limit_dsl() {
let connection = &mut connection_with_sean_and_tess_in_users_table();
let data = users::table.into_boxed().limit(1).load(connection);
let data = users::table
.into_boxed()
.limit(1)
.order(users::id)
.load(connection);
let expected_data = vec![find_user_by_name("Sean", connection)];
assert_eq!(Ok(expected_data), data);
}
Expand All @@ -104,6 +109,7 @@ fn boxed_queries_implement_offset_dsl() {
.into_boxed()
.limit(1)
.offset(1)
.order(users::id)
.load(connection);
let expected_data = vec![find_user_by_name("Tess", connection)];
assert_eq!(Ok(expected_data), data);
Expand Down Expand Up @@ -154,6 +160,7 @@ fn boxed_queries_implement_or_filter() {
.into_boxed()
.filter(users::name.eq("Sean"))
.or_filter(users::name.eq("Tess"))
.order(users::name)
.load(connection);
let expected = vec![
find_user_by_name("Sean", connection),
Expand Down
13 changes: 7 additions & 6 deletions diesel_tests/tests/combination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn union() {
NewUser::new("Jim", None),
];
insert_into(users).values(&data).execute(conn).unwrap();
let data = users.load::<User>(conn).unwrap();
let data = users.order(id).load::<User>(conn).unwrap();
let sean = &data[0];
let tess = &data[1];
let jim = &data[2];
Expand Down Expand Up @@ -43,7 +43,7 @@ fn union_all() {
NewUser::new("Jim", None),
];
insert_into(users).values(&data).execute(conn).unwrap();
let data = users.load::<User>(conn).unwrap();
let data = users.order(id).load::<User>(conn).unwrap();
let sean = &data[0];
let tess = &data[1];
let jim = &data[2];
Expand Down Expand Up @@ -75,10 +75,10 @@ fn intersect() {
NewUser::new("Jim", None),
];
insert_into(users).values(&data).execute(conn).unwrap();
let data = users.load::<User>(conn).unwrap();
let _sean = &data[0];
let tess = &data[1];
let _jim = &data[2];
let data = users.order(name).load::<User>(conn).unwrap();
let _sean = &data[1];
let tess = &data[2];
let _jim = &data[0];

let expected_data = vec![User::new(tess.id, "Tess")];
let data: Vec<_> = users
Expand Down Expand Up @@ -171,6 +171,7 @@ fn as_subquery_for_eq_in() {
let out = posts::table
.filter(posts::user_id.eq_any(subquery))
.select(posts::title)
.order_by(posts::title)
.load::<String>(conn)
.unwrap();

Expand Down
12 changes: 9 additions & 3 deletions diesel_tests/tests/deserialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ fn generated_queryable_allows_lifetimes() {
};
assert_eq!(
Ok(expected_user),
users.select((id, name)).first(connection)
users.select((id, name)).order(id).first(connection)
);
assert_eq!(
users.select((id, name)).first::<CowUser<'_>>(connection),
users.select(CowUser::as_select()).first(connection)
users
.select((id, name))
.order(id)
.first::<CowUser<'_>>(connection),
users
.select(CowUser::as_select())
.order(id)
.first(connection)
);
}

Expand Down
2 changes: 1 addition & 1 deletion diesel_tests/tests/distinct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ fn distinct_of_multiple_columns() {
.execute(&mut connection)
.unwrap();
let posts = posts::table
.order(posts::id)
.order(posts::title)
.load::<Post>(&mut connection)
.unwrap();

Expand Down
1 change: 1 addition & 0 deletions diesel_tests/tests/expressions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ fn function_with_multiple_arguments() {
let expected_data = vec!["black".to_string(), "Tess".to_string()];
let data = users
.select(coalesce(hair_color, name))
.order(id)
.load::<String>(connection);

assert_eq!(Ok(expected_data), data);
Expand Down
Loading
Loading