-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add github workflows #297
Merged
0xLucca
merged 3 commits into
polkadot-developers:master
from
UtkarshBhardwaj007:github-workflows
Jan 8, 2025
Merged
add github workflows #297
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
IMAGE="docker.io/paritytech/ci-unified:bullseye-1.81.0-2024-11-19-v202411281558" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: Checks | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '.snippets/code/**' | ||
- '.github/workflows/**' | ||
pull_request: | ||
types: [opened, synchronize, reopened, ready_for_review] | ||
paths: | ||
- '.snippets/code/**' | ||
- '.github/workflows/**' | ||
merge_group: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
preflight: | ||
uses: ./.github/workflows/reusable-preflight.yml | ||
|
||
fmt: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
needs: [preflight] | ||
container: | ||
image: ${{ needs.preflight.outputs.IMAGE }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Cargo fmt | ||
working-directory: .snippets/code | ||
run: cargo +nightly fmt --all -- --check | ||
|
||
clippy: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
needs: [preflight] | ||
container: | ||
image: ${{ needs.preflight.outputs.IMAGE }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Clippy check | ||
working-directory: .snippets/code | ||
run: | | ||
cargo clippy --all-targets --locked --workspace --quiet | ||
cargo clippy --all-targets --all-features --locked --workspace --quiet | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
needs: [preflight] | ||
container: | ||
image: ${{ needs.preflight.outputs.IMAGE }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run tests | ||
working-directory: .snippets/code | ||
run: cargo test | ||
|
||
check-fail-ci: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: "paritytech/tools:latest" | ||
options: --user root | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Check | ||
working-directory: .snippets/code | ||
run: | | ||
set +e | ||
rg --line-number --hidden --type rust --glob '!{.git,target}' "$ASSERT_REGEX" .; exit_status=$? | ||
if [ $exit_status -eq 0 ]; then | ||
echo "$ASSERT_REGEX was found, exiting with 1"; | ||
exit 1; | ||
else | ||
echo "No $ASSERT_REGEX was found, exiting with 0"; | ||
exit 0; | ||
fi | ||
env: | ||
ASSERT_REGEX: "FAIL-CI" | ||
GIT_DEPTH: 1 | ||
|
||
confirm-checks: | ||
runs-on: ubuntu-latest | ||
name: All checks passed | ||
needs: | ||
- fmt | ||
- clippy | ||
- test | ||
- check-fail-ci | ||
if: always() && !cancelled() | ||
steps: | ||
- run: | | ||
tee resultfile <<< '${{ toJSON(needs) }}' | ||
FAILURES=$(cat resultfile | grep '"result": "failure"' | wc -l) | ||
if [ $FAILURES -gt 0 ]; then | ||
echo "### At least one required job failed ❌" >> $GITHUB_STEP_SUMMARY | ||
exit 1 | ||
else | ||
echo '### Good job! All the required jobs passed 🚀' >> $GITHUB_STEP_SUMMARY | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Preflight | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
changes_rust: | ||
value: ${{ jobs.preflight.outputs.changes_rust }} | ||
changes_currentWorkflow: | ||
value: ${{ jobs.preflight.outputs.changes_currentWorkflow }} | ||
IMAGE: | ||
value: ${{ jobs.preflight.outputs.IMAGE }} | ||
description: "CI image" | ||
|
||
jobs: | ||
preflight: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
changes_rust: ${{ steps.set_changes.outputs.rust_any_changed || steps.set_changes.outputs.currentWorkflow_any_changed }} | ||
changes_currentWorkflow: ${{ steps.set_changes.outputs.currentWorkflow_any_changed }} | ||
IMAGE: ${{ steps.set_image.outputs.IMAGE }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Current file | ||
id: current_file | ||
shell: bash | ||
run: | | ||
echo "currentWorkflowFile=$(echo ${{ github.workflow_ref }} | sed -nE "s/.*(\.github\/workflows\/[a-zA-Z0-9_-]*\.y[a]?ml)@refs.*/\1/p")" >> $GITHUB_OUTPUT | ||
echo "currentActionDir=$(echo ${{ github.action_path }} | sed -nE "s/.*(\.github\/actions\/[a-zA-Z0-9_-]*)/\1/p")" >> $GITHUB_OUTPUT | ||
|
||
- name: Set changes | ||
id: set_changes | ||
uses: tj-actions/changed-files@v45 | ||
with: | ||
files_yaml: | | ||
rust: | ||
- '.snippets/code/**/*' | ||
- '!.github/**/*' | ||
- '!docs/**/*' | ||
currentWorkflow: | ||
- '${{ steps.current_file.outputs.currentWorkflowFile }}' | ||
- '.github/workflows/reusable-preflight.yml' | ||
|
||
- name: Set image | ||
id: set_image | ||
shell: bash | ||
run: cat .github/env >> $GITHUB_OUTPUT |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean the CI runs once when the PR is opened, when it receives a new commit, and when it is ready for review?
Perhaps it is good to remove
ready_for_review
to reduce the number of runs a bit?Or does this mean that if the PR is draft the CI won't run? that would be a good outcome :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and also when a closed PR is re-opened.
Yes the CI won't run in draft mode. Once it is published, the CI would run. For, any commits after opening the PR, the CI would run as well which is ideal.