Skip to content
This repository was archived by the owner on Dec 17, 2022. It is now read-only.

Commit 02ea8ec

Browse files
committed
chore: Add github action.
1 parent 2124a1b commit 02ea8ec

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

.github/workflows/ci.yml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
name: ${{ matrix.config.kind }} ${{ matrix.config.os }}
8+
runs-on: ${{ matrix.config.os }}
9+
strategy:
10+
matrix:
11+
config:
12+
- os: ubuntu-16.04
13+
kind: test_release
14+
- os: ubuntu-16.04
15+
kind: test_debug
16+
17+
env:
18+
CARGO_INCREMENTAL: 0
19+
RUST_BACKTRACE: full
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Install wasm32 target
24+
if: matrix.config.kind == 'test_release'
25+
run: rustup target add wasm32-unknown-unknown
26+
27+
- name: Install and use nightly compiler
28+
run: rustup default nightly
29+
30+
- name: Run setup script
31+
run: |
32+
chmod +x setup.sh
33+
./setup.sh
34+
35+
- name: Cache cargo registry
36+
uses: actions/cache@v1
37+
with:
38+
path: ~/.cargo/registry
39+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
40+
- name: Cache cargo index
41+
uses: actions/cache@v1
42+
with:
43+
path: ~/.cargo/git
44+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
45+
- name: Cache cargo build
46+
uses: actions/cache@v1
47+
with:
48+
path: target
49+
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
50+
51+
- name: Build debug
52+
if: matrix.config.kind == 'test_debug'
53+
run: cargo build --verbose
54+
- name: Build release
55+
if: matrix.config.kind == 'test_release'
56+
run: cargo build --target wasm32-unknown-unknown --release --verbose
57+
58+
- name: Test debug
59+
if: matrix.config.kind == 'test_debug'
60+
run: cargo test --verbose
61+
- name: Test release
62+
if: matrix.config.kind == 'test_release'
63+
run: cargo test --release --verbose
64+
65+
- name: Get tag version
66+
if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
67+
id: get_tag_version
68+
run: echo ::set-output name=TAG_VERSION::${GITHUB_REF/refs\/tags\//}
69+
70+
- name: Pre-release
71+
if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
72+
run: |
73+
cd target/wasm32-unknown-unknown/release/
74+
mv dprint_plugin_rustfmt.wasm rustfmt-${{ steps.get_tag_version.outputs.TAG_VERSION }}.wasm
75+
76+
- name: Release
77+
uses: softprops/action-gh-release@v1
78+
if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
with:
82+
files: |
83+
target/wasm32-unknown-unknown/release/rustfmt-${{ steps.get_tag_version.outputs.TAG_VERSION }}.wasm
84+
draft: true

0 commit comments

Comments
 (0)