Skip to content

Commit

Permalink
Artifacts and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Xithrius committed Jun 6, 2022
1 parent 110ece0 commit 1b600de
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 18 deletions.
72 changes: 59 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: CI

on:
push:
branches:
- main
branches: [ main ]
pull_request:

env:
Expand All @@ -15,25 +14,49 @@ jobs:
fail-fast: false

matrix:
os:
- { prettyname: Windows, fullname: windows-latest }
- { prettyname: macOS, fullname: macos-latest }
- { prettyname: Linux, fullname: ubuntu-latest }
include:
- os: windows-latest
target: x86_64-pc-windows-msvc

threadingMode: [ 'SingleThread', 'MultiThreaded' ]
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu

timeout-minutes: 60
- os: macos-latest
target: x86_64-apple-darwin

runs-on: ${{matrix.os.fullname}}
name: Build & Test (${{ matrix.target }})
runs-on: ${{ matrix.os }}

env:
RA_TARGET: ${{ matrix.target }}

steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
profile: minimal
override: true

- name: Install Rust library source
if: matrix.target == 'x86_64-unknown-linux-gnu'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
profile: minimal
override: true
components: rust-src

- name: Build
run: cargo build --verbose
run: cargo build --verbose --target ${{ matrix.target }}

- name: Run tests
run: cargo test --verbose
run: cargo test --verbose --target ${{ matrix.target }}

lint:
name: Formatter
Expand All @@ -43,7 +66,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Rust
run: |
Expand All @@ -57,3 +81,25 @@ jobs:

- name: Check code for possible improvements
run: cargo clippy -- -D warnings

# Prepare the Pull Request Payload artifact. If this fails, we
# we fail silently using the `continue-on-error` option. It's
# nice if this succeeds, but if it fails for any reason, it
# does not mean that our lint-test checks failed.
- name: Prepare Pull Request Payload artifact
id: prepare-artifact
if: always() && github.event_name == 'pull_request'
continue-on-error: true
run: cat $GITHUB_EVENT_PATH | jq '.pull_request' > pull_request_payload.json

# This only makes sense if the previous step succeeded. To
# get the original outcome of the previous step before the
# `continue-on-error` conclusion is applied, we use the
# `.outcome` value. This step also fails silently.
- name: Upload a Build Artifact
if: always() && steps.prepare-artifact.outcome == 'success'
continue-on-error: true
uses: actions/upload-artifact@v2
with:
name: pull-request-payload
path: pull_request_payload.json
22 changes: 17 additions & 5 deletions .github/workflows/status_embed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,25 @@ on:

jobs:
status_embed:
# We send the embed in the following situations:
# - Always after the `CI` workflow, as it runs at the
# end of our workflow sequence regardless of status.
# - Always for the `pull_request` event, as it only
# runs one workflow.
# - Always run for non-success workflows, as they
# terminate the workflow sequence.
if: >-
(github.event.workflow_run.name == 'CI' && github.event.workflow_run.conclusion != 'skipped') ||
github.event.workflow_run.event == 'pull_request' ||
github.event.workflow_run.conclusion == 'failure' ||
github.event.workflow_run.conclusion == 'cancelled'
name: Send Status Embed to Discord
runs-on: ubuntu-latest

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

# We need to provide the information of the workflow that
# triggered this workflow instead of this workflow.
# Workflow information
workflow_name: ${{ github.event.workflow_run.name }}
run_id: ${{ github.event.workflow_run.id }}
run_number: ${{ github.event.workflow_run.run_number }}
Expand All @@ -53,7 +66,6 @@ jobs:
ref: ${{ github.ref }}
sha: ${{ github.event.workflow_run.head_sha }}

# Now we can use the information extracted in the previous step:
pr_author_login: ${{ steps.pr_info.outputs.pr_author_login }}
pr_number: ${{ steps.pr_info.outputs.pr_number }}
pr_title: ${{ steps.pr_info.outputs.pr_title }}
Expand Down

0 comments on commit 1b600de

Please sign in to comment.