Author: Jason White [github@jasonwhite.io]
Committer: GitHub [noreply@github.com] Mon, 18 Oct 2021 04:04:49 +0000
Hash: e0c415c9a776426284387181d300343da4c9f4ef
Timestamp: Mon, 18 Oct 2021 04:04:49 +0000 (2 years ago)

+136 -65 +/-3 browse
Migrate to github actions (#37)
Migrate to github actions (#37)

1diff --git a/.cirrus.yml b/.cirrus.yml
2deleted file mode 100644
3index bd2b6de..0000000
4--- a/.cirrus.yml
5+++ /dev/null
6 @@ -1,64 +0,0 @@
7- # Check that formatting is correct using nightly rust.
8- fmt_task:
9- container:
10- image: rustlang/rust:nightly
11- install_script: rustup component add rustfmt-preview
12- check_script: cargo fmt -- --check
13-
14- # Run clippy.
15- clippy_task:
16- container:
17- image: rust:latest
18- cargo_cache:
19- folder: $CARGO_HOME/registry
20- fingerprint_script: cat Cargo.lock
21- install_script: rustup component add clippy
22- check_script: cargo clippy
23- before_cache_script: rm -rf $CARGO_HOME/registry/index
24-
25- # Build and test.
26- test_task:
27- matrix:
28- - container:
29- image: rust:latest
30- - allow_failures: true
31- container:
32- image: rustlang/rust:nightly
33- cargo_cache:
34- folder: $CARGO_HOME/registry
35- fingerprint_script: cat Cargo.lock
36- install_script: cd $(mktemp -d) && curl -Ls https://github.com/git-lfs/git-lfs/releases/download/v2.13.3/git-lfs-linux-amd64-v2.13.3.tar.gz | tar xvz && ./install.sh
37- build_script: cargo build
38- test_script: cargo test
39- before_cache_script: rm -rf $CARGO_HOME/registry/index
40-
41- # Publish Cargo releases
42- publish_task:
43- only_if: $CIRRUS_TAG != ''
44- depends_on:
45- - fmt
46- - clippy
47- - test
48- container:
49- image: rust:latest
50- env:
51- CARGO_TOKEN: ENCRYPTED[9d47772b21c821891037f85996e28eebf6d6afa38b24be0985085c1c48269ce6c1238357c8f81bdd4c2fb3d68e4ccc3b]
52- cargo_cache:
53- folder: $CARGO_HOME/registry
54- fingerprint_script: cat Cargo.lock
55- publish_script: cargo publish --no-verify --token "$CARGO_TOKEN"
56-
57- # Build releases
58- tag_docker_builder:
59- only_if: $CIRRUS_TAG != ''
60- env:
61- DOCKER_USERNAME: ENCRYPTED[e27aa1f15f278868b84497fd0fbd007127251ed44de671de28cee8c0669ff5b886980a409da9bae8c5cff6dbe88fe289]
62- DOCKER_PASSWORD: ENCRYPTED[491d248564335b8760a65f9c69f970d3ba6bf9ba169f9e6f93836e8a7360d13f421afd4630f71d8981182da0bf26c2dd]
63- build_script: docker build --tag jasonwhite0/rudolfs:$CIRRUS_TAG --tag jasonwhite0/rudolfs:latest .
64- login_script: echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
65- push_script: docker push jasonwhite0/rudolfs:$CIRRUS_TAG && docker push jasonwhite0/rudolfs:latest
66-
67- # Build the dockerfile, but don't publish it.
68- build_docker_builder:
69- only_if: $CIRRUS_TAG == ''
70- build_script: docker build .
71 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
72new file mode 100644
73index 0000000..40dfd6b
74--- /dev/null
75+++ b/.github/workflows/ci.yml
76 @@ -0,0 +1,135 @@
77+ name: ci
78+
79+ on:
80+ push:
81+ pull_request:
82+
83+ jobs:
84+ check:
85+ name: Check
86+ runs-on: ubuntu-latest
87+ steps:
88+ - name: Checkout sources
89+ uses: actions/checkout@v2
90+
91+ - name: Install stable toolchain
92+ uses: actions-rs/toolchain@v1
93+ with:
94+ profile: minimal
95+ toolchain: stable
96+ override: true
97+
98+ - name: Run cargo check
99+ uses: actions-rs/cargo@v1
100+ with:
101+ command: check
102+
103+ test:
104+ name: Test Suite
105+ runs-on: ubuntu-latest
106+ steps:
107+ - name: Checkout sources
108+ uses: actions/checkout@v2
109+
110+ - name: Install stable toolchain
111+ uses: actions-rs/toolchain@v1
112+ with:
113+ profile: minimal
114+ toolchain: stable
115+ override: true
116+
117+ - name: Run cargo test
118+ uses: actions-rs/cargo@v1
119+ with:
120+ command: test
121+
122+ rustfmt:
123+ name: Check format
124+ runs-on: ubuntu-latest
125+ steps:
126+ - name: Checkout sources
127+ uses: actions/checkout@v2
128+
129+ - name: Install stable toolchain
130+ uses: actions-rs/toolchain@v1
131+ with:
132+ profile: minimal
133+ toolchain: nightly
134+ override: true
135+ components: rustfmt
136+
137+ - name: Run cargo fmt
138+ uses: actions-rs/cargo@v1
139+ with:
140+ command: fmt
141+ args: --all -- --check
142+
143+ clippy:
144+ name: Clippy
145+ runs-on: ubuntu-latest
146+ steps:
147+ - uses: actions/checkout@v2
148+ - uses: actions-rs/toolchain@v1
149+ with:
150+ toolchain: nightly
151+ components: clippy
152+ override: true
153+ - uses: actions-rs/clippy-check@v1
154+ with:
155+ token: ${{ secrets.GITHUB_TOKEN }}
156+
157+ publish_crate:
158+ name: Publish Crate
159+ # Don't publish unless all the checks pass.
160+ needs: [check, test, clippy, rustfmt]
161+ # Only publish for tags
162+ if: ${{ startsWith(github.event.ref, 'refs/tags/') }}
163+ runs-on: ubuntu-latest
164+ steps:
165+ - name: Checkout sources
166+ uses: actions/checkout@v1
167+
168+ - name: cargo login
169+ uses: actions-rs/cargo@v1
170+ with:
171+ command: login
172+ args: ${{ secrets.CARGO_TOKEN }}
173+
174+ - name: publish
175+ run: cargo publish --no-verify
176+
177+ docker:
178+ name: Push Docker Image
179+ needs: [check, test]
180+ runs-on: ubuntu-latest
181+ steps:
182+ -
183+ name: Checkout sources
184+ uses: actions/checkout@v2
185+ -
186+ name: Docker meta
187+ id: meta
188+ uses: docker/metadata-action@v3
189+ with:
190+ images: jasonwhite0/rudolfs
191+ tags: |
192+ type=ref,event=branch
193+ type=ref,event=pr
194+ type=semver,pattern={{version}}
195+ -
196+ name: Login to DockerHub
197+ if: ${{ github.event_name != 'pull_request' }}
198+ uses: docker/login-action@v1
199+ with:
200+ username: ${{ secrets.DOCKERHUB_USERNAME }}
201+ password: ${{ secrets.DOCKERHUB_TOKEN }}
202+ -
203+ name: Build and push
204+ uses: docker/build-push-action@v2
205+ with:
206+ context: .
207+ push: ${{ github.event_name != 'pull_request' }}
208+ tags: ${{ steps.meta.outputs.tags }}
209+ labels: ${{ steps.meta.outputs.labels }}
210+
211+
212 diff --git a/Dockerfile b/Dockerfile
213index 7b0e797..6947001 100644
214--- a/Dockerfile
215+++ b/Dockerfile
216 @@ -1,4 +1,4 @@
217- FROM rust:1.49 as build
218+ FROM rust:1.55 as build
219
220 ENV CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
221