Skip to content

Commit

Permalink
fix: gh action slack notification (#697)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdankel authored Jan 23, 2025
1 parent b9187b8 commit 0f12783
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 47 deletions.
62 changes: 38 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
SHFMT_OPTS: -i 4 -ci
with:
sh_checker_comment: false
sh_checker_exclude: "src"
sh_checker_exclude: 'src'

publish-codecov:
name: Check code coverage (branch)
Expand All @@ -54,7 +54,7 @@ jobs:

- name: Code coverage report
run: cargo +${{ env.RUST_VERSION_COV }} llvm-cov --all-features --lcov --branch --output-path lcov.info

- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1

Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v1

- name: Check Clippy Linter
Expand All @@ -104,10 +104,10 @@ jobs:

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable

- name: Check Formatting
run: cargo fmt --all -- --check

cargo-test-workspace:
needs: cancel-previous-runs
runs-on: ubuntu-latest
Expand All @@ -116,10 +116,10 @@ jobs:

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable

- name: Run tests
run: cargo test --locked --workspace

lint-toml-files:
needs: cancel-previous-runs
runs-on: ubuntu-latest
Expand All @@ -130,12 +130,12 @@ jobs:

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install Cargo.toml linter
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-toml-lint
version: "0.1"
version: '0.1'

- name: Run Cargo.toml linter
run: git ls-files | grep Cargo.toml$ | xargs --verbose -n 1 cargo-toml-lint
Expand All @@ -156,17 +156,6 @@ jobs:
curl -sSLf "https://github.com/TomWright/dasel/releases/download/v1.24.3/dasel_linux_amd64" -L -o dasel && chmod +x dasel
mv ./dasel /usr/local/bin/dasel
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} Cargo.toml
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v1
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TOOLING }}
build-release:
name: build fuelup release binaries
Expand Down Expand Up @@ -200,13 +189,13 @@ jobs:
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
key: "${{ matrix.job.target }}"
key: '${{ matrix.job.target }}'

- name: Use Cross
uses: baptiste0928/cargo-install@v1
with:
crate: cross
cache-key: "${{ matrix.job.target }}"
cache-key: '${{ matrix.job.target }}'

- name: Build fuelup
run: |
Expand Down Expand Up @@ -259,8 +248,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}
with:
files:
${{ env.ZIP_FILE_NAME }}
files: ${{ env.ZIP_FILE_NAME }}

post-release-checks:
name: Do post-release checks
Expand All @@ -277,3 +265,29 @@ jobs:
uses: actions/checkout@v3
- name: Try fuelup installation with fuelup-init
run: ./fuelup-init.sh

notify-slack-on-failure:
if: failure()
needs:
[
publish-codecov,
try-run-fuelup-init,
cargo-clippy,
cargo-fmt-check,
cargo-test-workspace,
lint-toml-files,
publish-check,
build-release,
post-release-checks,
]
runs-on: ubuntu-latest
steps:
- uses: ravsamhq/notify-slack-action@v1
with:
status: 'failure'
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: '{workflow} has {status_message}'
message_format: '{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>'
footer: ''
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TOOLING }}
19 changes: 11 additions & 8 deletions .github/workflows/nightly-cargo-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ jobs:
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v1

notify-slack-on-failure:
if: failure()
needs: [cargo_audit]
runs-on: ubuntu-latest
steps:
- uses: ravsamhq/notify-slack-action@v1
with:
status: ${{ job.status }}
status: 'failure'
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
notification_title: '{workflow} has {status_message}'
message_format: '{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>'
footer: ''
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TOOLING }}

33 changes: 18 additions & 15 deletions .github/workflows/publish-nightly-channel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ jobs:

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install build-channel script
run: cargo install --debug --path ./ci/build-channel

- name: Publish nightly channel
id: setup
run: |
PUBLISHED_DATE=$(date +'%Y-%m-%d')
FORMATTED_PUBLISHED_DATE=$(date +'%Y/%m/%d')
mkdir -p ${{ env.NIGHTLY_CHANNEL_DIR }}
PUBLISHED_DATE=$(date +'%Y-%m-%d')
FORMATTED_PUBLISHED_DATE=$(date +'%Y/%m/%d')
mkdir -p ${{ env.NIGHTLY_CHANNEL_DIR }}
CHANNEL_TOML="channel-fuel-nightly.toml"
CHANNEL_TOML="channel-fuel-nightly.toml"
build-channel --nightly $CHANNEL_TOML $PUBLISHED_DATE --github-run-id $GITHUB_RUN_ID
build-channel --nightly $CHANNEL_TOML $PUBLISHED_DATE --github-run-id $GITHUB_RUN_ID
cp $CHANNEL_TOML ${{ env.NIGHTLY_CHANNEL_DIR }}
cp $CHANNEL_TOML ${{ env.NIGHTLY_CHANNEL_DIR }}
echo "::set-output name=archive_dir::channels/nightly/${FORMATTED_PUBLISHED_DATE}"
echo "::set-output name=archive_dir::channels/nightly/${FORMATTED_PUBLISHED_DATE}"
- name: Deploy nightly channel (latest version)
uses: peaceiris/actions-gh-pages@v3
Expand All @@ -58,14 +58,17 @@ jobs:
user_name: 'fuel-service-user'
user_email: 'fuel-service-user@users.noreply.github.com'

- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v1
notify-slack-on-failure:
if: failure()
needs: [publish-channel]
runs-on: ubuntu-latest
steps:
- uses: ravsamhq/notify-slack-action@v1
with:
status: ${{ job.status }}
status: 'failure'
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
notification_title: '{workflow} has {status_message}'
message_format: '{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>'
footer: ''
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TOOLING }}

0 comments on commit 0f12783

Please # to comment.