Skip to content
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

fix: improve GHA code re-use #4612

Merged
merged 17 commits into from
Aug 6, 2024
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
7 changes: 5 additions & 2 deletions .github/actions/check-crate/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ inputs:
runs:
using: "composite"
steps:
- uses: ./.github/actions/init-env-rust
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
with:
shared-key: unix-rust-testing
key: ${{ inputs.features }}


- run: |
printf '%s\n' "$JSON_DOC" > /tmp/features.json
cat /tmp/features.json | jq -r 'if . == "*" then "--all-features" elif . == "" then "" elif type == "array" then if length == 0 then "--no-default-features" else "--no-default-features --features " + join(",") end else . end' > /tmp/features
Expand All @@ -27,10 +25,15 @@ runs:
cargo test --workspace $(cat /tmp/features)
env:
GITBUTLER_TESTS_NO_CLEANUP: "1"
CARGO_TERM_COLOR: always
shell: bash

- run: cargo clippy --workspace $(cat /tmp/features) -- -D warnings
env:
CARGO_TERM_COLOR: always
shell: bash

- run: cargo clippy --workspace --tests $(cat /tmp/features) -- -D warnings
env:
CARGO_TERM_COLOR: always
shell: bash
28 changes: 2 additions & 26 deletions .github/actions/init-env-node/action.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,16 @@
name: init-node
description: prepare runner for node related tasks
name: init-env-node
description: Prepare Node.js Environment
runs:
using: "composite"
steps:
- uses: pnpm/action-setup@v4
name: Install pnpm

- uses: actions/setup-node@v4
name: Setup node
with:
cache: pnpm
node-version-file: '.nvmrc'

- name: Get pnpm store directory
shell: bash
run: echo 'STORE_PATH=$(pnpm store path --silent)' >> $GITHUB_ENV

- uses: actions/cache@v4
if: runner.name != 'ScottsMacStudio' # internet in berlin is very slow
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: github-client-${{ runner.os }}-pnpm-store

- name: Git config
shell: bash
run: |
# This seems the only reliable way of forcing https for forked packages
git config --global url."https://".insteadOf git://
git config --global url."https://github.com/".insteadOf git@github.com:

- name: Install dependencies
shell: bash
run: pnpm install

- name: Build UI
shell: bash
run: pnpm exec turbo run package

17 changes: 0 additions & 17 deletions .github/actions/init-env-rust/action.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Init Node Environment
uses: ./.github/actions/init-env-node
- name: Build SvelteKit
run: pnpm build -- --mode ${{ env.vitemode }}
run: pnpm build:desktop -- --mode ${{ env.vitemode }}
env:
SENTRY_RELEASE: ${{ env.version }}
- uses: actions/upload-artifact@v4
Expand All @@ -77,6 +77,8 @@ jobs:

build-tauri:
needs: build-sveltekit
env:
CARGO_TERM_COLOR: always
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -124,8 +126,6 @@ jobs:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT_JUNON }} # custom token here so that we can push tags later
- name: Init Rust Environment
uses: ./.github/actions/init-env-rust
- name: Init Node Environment
uses: ./.github/actions/init-env-node

Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ jobs:
runs-on: ubuntu-latest
container:
image: ghcr.io/gitbutlerapp/ci-base-image:latest
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/init-env-rust
- run: cargo fmt --check --all

rust-docs:
Expand All @@ -80,9 +81,10 @@ jobs:
runs-on: ubuntu-latest
container:
image: ghcr.io/gitbutlerapp/ci-base-image:latest
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/init-env-rust
# TODO(qix-): we have to exclude the app here for now because for some
# TODO(qix-): reason it doesn't build with the docs feature enabled.
- run: cargo doc --no-deps --all-features --document-private-items -p gitbutler-git
Expand All @@ -95,6 +97,8 @@ jobs:
runs-on: ubuntu-latest
container:
image: ghcr.io/gitbutlerapp/ci-base-image:latest
env:
CARGO_TERM_COLOR: always
strategy:
matrix:
# Specifies which features should be applied when running the checks and tests
Expand Down Expand Up @@ -122,6 +126,8 @@ jobs:
- rust-test
- rust-lint
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
Expand All @@ -133,9 +139,10 @@ jobs:
needs: changes
runs-on: windows-latest
if: ${{ needs.changes.outputs.rust == 'true' }}
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/init-env-rust
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
with:
Expand Down
40 changes: 26 additions & 14 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
name: E2E Tests
on:
schedule:
- cron: "0 6 * * *"
workflow_dispatch:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
inputs:
sha:
type: string
required: false
description: Target SHA

jobs:
test:
name: Run WebdriverIO Tests
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.sha }}
- name: Install Tauri OS dependencies
run: |
sudo apt update && sudo apt install -y \
Expand All @@ -23,22 +28,29 @@ jobs:
webkit2gtk-driver \
xvfb
- name: Setup rust-toolchain stable
id: rust-toolchain
uses: dtolnay/rust-toolchain@stable
- name: Setup node latest
uses: actions/setup-node@v4
- uses: actions/cache@v3
with:
node-version: latest
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Install dependencies
shell: bash
run: pnpm install
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-${{ steps.rust-toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: cargo-
- name: Setup node environment
uses: ./.github/actions/init-env-node
- name: Build SvelteKit
run: pnpm build:desktop -- --mode development
- name: Build Tauri
run: pnpm build:test
- name: Install tauri-driver
run: cargo install tauri-driver@0.1.3
run: |
if [ ! -e "$HOME/.cargo/bin/tauri-driver" ]; then
cargo install tauri-driver@0.1.3
fi

# Run it through `xvfb-run` to have a fake display server which allows our
# application to run headless without any changes to the code
Expand Down
Loading