Skip to content

Commit 9a14bc8

Browse files
authored
Merge pull request #22 from qryxip/ja-all-enabled-github-actions
Use GitHub Actions
2 parents 1b1cda4 + 06ab38f commit 9a14bc8

File tree

4 files changed

+136
-5
lines changed

4 files changed

+136
-5
lines changed

.github/workflows/ci.yml

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: CI
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 1 * *'
6+
push:
7+
pull_request:
8+
9+
jobs:
10+
rustfmt:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
# Breaking changes like this might be mixed into the future stable versions.
15+
# https://github.com/rust-lang/rustfmt/pull/3632
16+
channel:
17+
- 1.38.0
18+
- stable
19+
20+
name: Rustfmt (${{ matrix.channel }})
21+
runs-on: ubuntu-18.04
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v1
26+
27+
- name: rust-toolchain
28+
uses: actions-rs/toolchain@v1
29+
with:
30+
toolchain: ${{ matrix.channel }}-x86_64-unknown-linux-gnu
31+
override: true
32+
profile: default
33+
34+
- name: '`cargo fmt -- --check`'
35+
uses: actions-rs/cargo@v1
36+
with:
37+
command: fmt
38+
args: --all -- --check
39+
40+
build:
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
toolchain:
45+
# `x86_64-pc-windows-msvc` is tier 1 **for now**.
46+
- 1.38.0-x86_64-pc-windows-msvc
47+
- 1.38.0-x86_64-pc-windows-gnu
48+
- 1.38.0-x86_64-apple-darwin
49+
- 1.38.0-x86_64-unknown-linux-gnu
50+
- stable-x86_64-pc-windows-msvc
51+
- stable-x86_64-pc-windows-gnu
52+
- stable-x86_64-apple-darwin
53+
- stable-x86_64-unknown-linux-gnu
54+
- beta-x86_64-pc-windows-msvc
55+
- beta-x86_64-pc-windows-gnu
56+
- beta-x86_64-apple-darwin
57+
- beta-x86_64-unknown-linux-gnu
58+
include:
59+
- toolchain: 1.38.0-x86_64-pc-windows-msvc
60+
os: windows-latest
61+
- toolchain: 1.38.0-x86_64-pc-windows-gnu
62+
os: windows-latest
63+
- toolchain: 1.38.0-x86_64-apple-darwin
64+
os: macOS-latest
65+
- toolchain: 1.38.0-x86_64-unknown-linux-gnu
66+
os: ubuntu-18.04
67+
- toolchain: stable-x86_64-pc-windows-msvc
68+
os: windows-latest
69+
- toolchain: stable-x86_64-pc-windows-gnu
70+
os: windows-latest
71+
- toolchain: stable-x86_64-apple-darwin
72+
os: macOS-latest
73+
- toolchain: stable-x86_64-unknown-linux-gnu
74+
os: ubuntu-18.04
75+
- toolchain: beta-x86_64-pc-windows-msvc
76+
os: windows-latest
77+
- toolchain: beta-x86_64-pc-windows-gnu
78+
os: windows-latest
79+
- toolchain: beta-x86_64-apple-darwin
80+
os: macOS-latest
81+
- toolchain: beta-x86_64-unknown-linux-gnu
82+
os: ubuntu-18.04
83+
84+
name: ${{ matrix.toolchain }}
85+
runs-on: ${{ matrix.os }}
86+
87+
steps:
88+
- name: '`git config --global core.autocrlf false`'
89+
run: git config --global core.autocrlf false
90+
if: matrix.os == 'windows-latest'
91+
92+
- name: Checkout
93+
uses: actions/checkout@v1
94+
95+
- name: rust-toolchain
96+
uses: actions-rs/toolchain@v1
97+
with:
98+
toolchain: ${{ matrix.toolchain }}
99+
override: true
100+
profile: default
101+
102+
- name: Determine features
103+
id: features
104+
run: |
105+
if ${{ matrix.os == 'windows-latest' }}; then
106+
echo '::set-output name=features::--no-default-features'
107+
else
108+
echo '::set-output name=features::--all-features'
109+
fi
110+
shell: bash
111+
112+
- name: '`cargo clippy`'
113+
uses: actions-rs/cargo@v1
114+
with:
115+
command: clippy
116+
args: ${{ steps.features.outputs.features }} -- -D warnings
117+
118+
- name: '`cargo test`'
119+
uses: actions-rs/cargo@v1
120+
with:
121+
command: test
122+
args: ${{ steps.features.outputs.features }} --no-fail-fast
123+
124+
- name: '`cargo run --release`'
125+
uses: actions-rs/cargo@v1
126+
with:
127+
command: run
128+
args: ${{ steps.features.outputs.features }} --release

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

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

5+
[![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)
6+
57
このリポジトリには[AtCoder][atcoder]コンテスト(競技プログラミング)にRustで参加するためのCargoパッケージテンプレートが用意されています。
68
パッケージは[cargo-generate][cargo-generate-crate]で作成します。
79

src/main.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn run_ascii() -> UnitResult {
225225
use std::str::FromStr;
226226

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

@@ -255,7 +255,7 @@ fn run_bitset_fixed() {
255255
use rand::prelude::*;
256256
use rand_distr::Uniform;
257257

258-
let rng = StdRng::seed_from_u64(114514);
258+
let rng = StdRng::seed_from_u64(114_514);
259259
let dist = Uniform::from(0..2000);
260260

261261
let n = rng
@@ -345,9 +345,9 @@ fn run_rustc_hash() {
345345

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

418418
// regex and lazy_static
419419
// these codes were taken from examples on: https://docs.rs/regex/1.1.7/regex/
420+
#[allow(clippy::trivial_regex)]
420421
fn run_regex() -> UnitResult {
421422
use lazy_static::lazy_static;
422423
use regex::{Regex, RegexSet};

tests/test_jemallocator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn do_allocate_heap() -> UnitResult {
2121
use jemalloc_ctl::{epoch, stats};
2222
use rand::prelude::*;
2323

24-
const SIZE: usize = 100000;
24+
const SIZE: usize = 100_000;
2525

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

0 commit comments

Comments
 (0)