Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,31 @@ jobs:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Detect changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
workspace:
- '.github/workflows/trunk-on-push.yml'
- 'src/**'
- 'Cargo.lock'
- 'Cargo.toml'
shelltools:
- 'tools/shell/**'
- name: Workspace changed
id: workspace-changed
run: |
bash ./tools/shell/actions/detect-changes.sh \
--pattern '^src/.*$' \
--compare-with origin/${{ github.base_ref }}
if [[ -f "$GITHUB_OUTPUT" ]] && grep -q "changed_files" "$GITHUB_OUTPUT"; then
echo "change=true" >> $GITHUB_OUTPUT
else
echo "change=false" >> $GITHUB_OUTPUT
fi

- name: Workspace changed
id: shelltools-changed
run: |
bash ./tools/shell/actions/detect-changes.sh \
--pattern '^tools/shell/.*$' \
--compare-with origin/${{ github.base_ref }}
if [[ -f "$GITHUB_OUTPUT" ]] && grep -q "changed_files" "$GITHUB_OUTPUT"; then
echo "change=true" >> $GITHUB_OUTPUT
else
echo "change=false" >> $GITHUB_OUTPUT
fi

- name: Workspace cache
id: workspace-cache
uses: ./.github/actions/workspace-cache

- name: Validate the commit messages
Expand All @@ -55,34 +65,34 @@ jobs:
deactivate

- name: Install rust
if: steps.changes.outputs.workspace == 'true'
if: steps.workspace-changed.outputs.change == 'true'
run: |
sudo apt-get update
sudo apt-get install libfontconfig1-dev
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

- name: Install project dependencies
if: steps.changes.outputs.workspace == 'true'
if: steps.workspace-changed.outputs.change == 'true'
run: cargo install --path . --force

- name: Check formatting
if: steps.changes.outputs.workspace == 'true'
if: steps.workspace-changed.outputs.change == 'true'
run: cargo fmt -- --check

- name: Lint sources
if: steps.changes.outputs.workspace == 'true'
if: steps.workspace-changed.outputs.change == 'true'
run: cargo clippy -- -D warnings

- name: Unit test
if: steps.changes.outputs.workspace == 'true'
if: steps.workspace-changed.outputs.change == 'true'
run: cargo test

- name: Build test
if: steps.changes.outputs.workspace == 'true'
if: steps.workspace-changed.outputs.change == 'true'
run: cargo build

- name: Lint shell
if: steps.changes.outputs.workspace == 'true'
if: steps.shelltools-changed.outputs.change == 'true'
run: |
sudo apt install shellcheck
shellcheck tools/shell/*.sh tools/shell/utils/*.sh
Loading
Loading