Skip to content

Commit 1b600de

Browse files
committed
Artifacts and comments
1 parent 110ece0 commit 1b600de

File tree

2 files changed

+76
-18
lines changed

2 files changed

+76
-18
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: [ main ]
76
pull_request:
87

98
env:
@@ -15,25 +14,49 @@ jobs:
1514
fail-fast: false
1615

1716
matrix:
18-
os:
19-
- { prettyname: Windows, fullname: windows-latest }
20-
- { prettyname: macOS, fullname: macos-latest }
21-
- { prettyname: Linux, fullname: ubuntu-latest }
17+
include:
18+
- os: windows-latest
19+
target: x86_64-pc-windows-msvc
2220

23-
threadingMode: [ 'SingleThread', 'MultiThreaded' ]
21+
- os: ubuntu-latest
22+
target: x86_64-unknown-linux-gnu
2423

25-
timeout-minutes: 60
24+
- os: macos-latest
25+
target: x86_64-apple-darwin
2626

27-
runs-on: ${{matrix.os.fullname}}
27+
name: Build & Test (${{ matrix.target }})
28+
runs-on: ${{ matrix.os }}
29+
30+
env:
31+
RA_TARGET: ${{ matrix.target }}
2832

2933
steps:
30-
- uses: actions/checkout@v2
34+
- name: Checkout repository
35+
uses: actions/checkout@v3
36+
37+
- name: Install Rust toolchain
38+
uses: actions-rs/toolchain@v1
39+
with:
40+
toolchain: stable
41+
target: ${{ matrix.target }}
42+
profile: minimal
43+
override: true
44+
45+
- name: Install Rust library source
46+
if: matrix.target == 'x86_64-unknown-linux-gnu'
47+
uses: actions-rs/toolchain@v1
48+
with:
49+
toolchain: stable
50+
target: ${{ matrix.target }}
51+
profile: minimal
52+
override: true
53+
components: rust-src
3154

3255
- name: Build
33-
run: cargo build --verbose
56+
run: cargo build --verbose --target ${{ matrix.target }}
3457

3558
- name: Run tests
36-
run: cargo test --verbose
59+
run: cargo test --verbose --target ${{ matrix.target }}
3760

3861
lint:
3962
name: Formatter
@@ -43,7 +66,8 @@ jobs:
4366
runs-on: ubuntu-latest
4467

4568
steps:
46-
- uses: actions/checkout@v2
69+
- name: Checkout repository
70+
uses: actions/checkout@v3
4771

4872
- name: Install Rust
4973
run: |
@@ -57,3 +81,25 @@ jobs:
5781

5882
- name: Check code for possible improvements
5983
run: cargo clippy -- -D warnings
84+
85+
# Prepare the Pull Request Payload artifact. If this fails, we
86+
# we fail silently using the `continue-on-error` option. It's
87+
# nice if this succeeds, but if it fails for any reason, it
88+
# does not mean that our lint-test checks failed.
89+
- name: Prepare Pull Request Payload artifact
90+
id: prepare-artifact
91+
if: always() && github.event_name == 'pull_request'
92+
continue-on-error: true
93+
run: cat $GITHUB_EVENT_PATH | jq '.pull_request' > pull_request_payload.json
94+
95+
# This only makes sense if the previous step succeeded. To
96+
# get the original outcome of the previous step before the
97+
# `continue-on-error` conclusion is applied, we use the
98+
# `.outcome` value. This step also fails silently.
99+
- name: Upload a Build Artifact
100+
if: always() && steps.prepare-artifact.outcome == 'success'
101+
continue-on-error: true
102+
uses: actions/upload-artifact@v2
103+
with:
104+
name: pull-request-payload
105+
path: pull_request_payload.json

.github/workflows/status_embed.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,25 @@ on:
99

1010
jobs:
1111
status_embed:
12+
# We send the embed in the following situations:
13+
# - Always after the `CI` workflow, as it runs at the
14+
# end of our workflow sequence regardless of status.
15+
# - Always for the `pull_request` event, as it only
16+
# runs one workflow.
17+
# - Always run for non-success workflows, as they
18+
# terminate the workflow sequence.
19+
if: >-
20+
(github.event.workflow_run.name == 'CI' && github.event.workflow_run.conclusion != 'skipped') ||
21+
github.event.workflow_run.event == 'pull_request' ||
22+
github.event.workflow_run.conclusion == 'failure' ||
23+
github.event.workflow_run.conclusion == 'cancelled'
1224
name: Send Status Embed to Discord
1325
runs-on: ubuntu-latest
1426

1527
steps:
16-
# Process the artifact uploaded in the `pull_request`-triggered workflow:
28+
# A workflow_run event does not contain all the information
29+
# we need for a PR embed. That's why we upload an artifact
30+
# with that information in the Lint workflow.
1731
- name: Get Pull Request Information
1832
id: pr_info
1933
if: github.event.workflow_run.event == 'pull_request'
@@ -38,12 +52,11 @@ jobs:
3852
- name: GitHub Actions Status Embed for Discord
3953
uses: SebastiaanZ/github-status-embed-for-discord@main
4054
with:
41-
# Webhook token
55+
# Our GitHub Actions webhook
4256
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
4357
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
4458

45-
# We need to provide the information of the workflow that
46-
# triggered this workflow instead of this workflow.
59+
# Workflow information
4760
workflow_name: ${{ github.event.workflow_run.name }}
4861
run_id: ${{ github.event.workflow_run.id }}
4962
run_number: ${{ github.event.workflow_run.run_number }}
@@ -53,7 +66,6 @@ jobs:
5366
ref: ${{ github.ref }}
5467
sha: ${{ github.event.workflow_run.head_sha }}
5568

56-
# Now we can use the information extracted in the previous step:
5769
pr_author_login: ${{ steps.pr_info.outputs.pr_author_login }}
5870
pr_number: ${{ steps.pr_info.outputs.pr_number }}
5971
pr_title: ${{ steps.pr_info.outputs.pr_title }}

0 commit comments

Comments
 (0)