Skip to content

Use GitHub Actions #22

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

Merged
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
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: CI

on:
schedule:
- cron: '0 0 1 * *'
push:
pull_request:

jobs:
rustfmt:
strategy:
fail-fast: false
matrix:
# Breaking changes like this might be mixed into the future stable versions.
# https://github.com/rust-lang/rustfmt/pull/3632
channel:
- 1.38.0
- stable

name: Rustfmt (${{ matrix.channel }})
runs-on: ubuntu-18.04

steps:
- name: Checkout
uses: actions/checkout@v1

- name: rust-toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.channel }}-x86_64-unknown-linux-gnu
override: true
profile: default

- name: '`cargo fmt -- --check`'
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

build:
strategy:
fail-fast: false
matrix:
toolchain:
# `x86_64-pc-windows-msvc` is tier 1 **for now**.
- 1.38.0-x86_64-pc-windows-msvc
- 1.38.0-x86_64-pc-windows-gnu
- 1.38.0-x86_64-apple-darwin
- 1.38.0-x86_64-unknown-linux-gnu
- stable-x86_64-pc-windows-msvc
- stable-x86_64-pc-windows-gnu
- stable-x86_64-apple-darwin
- stable-x86_64-unknown-linux-gnu
- beta-x86_64-pc-windows-msvc
- beta-x86_64-pc-windows-gnu
- beta-x86_64-apple-darwin
- beta-x86_64-unknown-linux-gnu
include:
- toolchain: 1.38.0-x86_64-pc-windows-msvc
os: windows-latest
- toolchain: 1.38.0-x86_64-pc-windows-gnu
os: windows-latest
- toolchain: 1.38.0-x86_64-apple-darwin
os: macOS-latest
- toolchain: 1.38.0-x86_64-unknown-linux-gnu
os: ubuntu-18.04
- toolchain: stable-x86_64-pc-windows-msvc
os: windows-latest
- toolchain: stable-x86_64-pc-windows-gnu
os: windows-latest
- toolchain: stable-x86_64-apple-darwin
os: macOS-latest
- toolchain: stable-x86_64-unknown-linux-gnu
os: ubuntu-18.04
- toolchain: beta-x86_64-pc-windows-msvc
os: windows-latest
- toolchain: beta-x86_64-pc-windows-gnu
os: windows-latest
- toolchain: beta-x86_64-apple-darwin
os: macOS-latest
- toolchain: beta-x86_64-unknown-linux-gnu
os: ubuntu-18.04

name: ${{ matrix.toolchain }}
runs-on: ${{ matrix.os }}

steps:
- name: '`git config --global core.autocrlf false`'
run: git config --global core.autocrlf false
if: matrix.os == 'windows-latest'

- name: Checkout
uses: actions/checkout@v1

- name: rust-toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
profile: default

- name: Determine features
id: features
run: |
if ${{ matrix.os == 'windows-latest' }}; then
echo '::set-output name=features::--no-default-features'
else
echo '::set-output name=features::--all-features'
fi
shell: bash

- name: '`cargo clippy`'
uses: actions-rs/cargo@v1
with:
command: clippy
args: ${{ steps.features.outputs.features }} -- -D warnings

- name: '`cargo test`'
uses: actions-rs/cargo@v1
with:
command: test
args: ${{ steps.features.outputs.features }} --no-fail-fast

- name: '`cargo run --release`'
uses: actions-rs/cargo@v1
with:
command: run
args: ${{ steps.features.outputs.features }} --release
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# AtCoder Rust Base (`ja-all-enabled`)

[![CI](https://github.com/rust-lang-ja/atcoder-rust-base/workflows/CI/badge.svg)](https://github.com/rust-lang-ja/atcoder-rust-base/actions?workflow=CI)

このリポジトリには[AtCoder][atcoder]コンテスト(競技プログラミング)にRustで参加するためのCargoパッケージテンプレートが用意されています。
パッケージは[cargo-generate][cargo-generate-crate]で作成します。

Expand Down
9 changes: 5 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn run_ascii() -> UnitResult {
use std::str::FromStr;

let s = AsciiString::from_str("2019-07-01")?;
let mut ix = s.as_str().match_indices("-");
let mut ix = s.as_str().match_indices('-');
let (i0, _) = ix.next().ok_or_else(|| "got none")?;
let (i1, _) = ix.next().ok_or_else(|| "got none")?;

Expand Down Expand Up @@ -255,7 +255,7 @@ fn run_bitset_fixed() {
use rand::prelude::*;
use rand_distr::Uniform;

let rng = StdRng::seed_from_u64(114514);
let rng = StdRng::seed_from_u64(114_514);
let dist = Uniform::from(0..2000);

let n = rng
Expand Down Expand Up @@ -345,9 +345,9 @@ fn run_rustc_hash() {

let mut map = [('c', "Cindy"), ('a', "Alice"), ('b', "Bob")]
.iter()
.map(|(c, s)| (*c, s.to_string()))
.map(|&(c, s)| (c, s.to_string()))
.collect::<FxHashMap<_, _>>();
map.entry('d').or_insert("Denis".to_string());
map.entry('d').or_insert_with(|| "Denis".to_string());
map.insert('a', "Alexa".to_string());
assert_eq!(map.len(), 4);
}
Expand Down Expand Up @@ -417,6 +417,7 @@ fn calc_mean<D: rand_distr::Distribution<f64>>(rng: &mut impl rand::Rng, distr:

// regex and lazy_static
// these codes were taken from examples on: https://docs.rs/regex/1.1.7/regex/
#[allow(clippy::trivial_regex)]
fn run_regex() -> UnitResult {
use lazy_static::lazy_static;
use regex::{Regex, RegexSet};
Expand Down
2 changes: 1 addition & 1 deletion tests/test_jemallocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn do_allocate_heap() -> UnitResult {
use jemalloc_ctl::{epoch, stats};
use rand::prelude::*;

const SIZE: usize = 100000;
const SIZE: usize = 100_000;

let mut rng = SmallRng::from_rng(thread_rng())?;

Expand Down