Skip to content

Commit

Permalink
test: migrate e2e to rust (#629)
Browse files Browse the repository at this point in the history
* wip: enhance release ci

* update PR checklist

* wip: rewrite e2e in rust

* add e2e cargo module

* rewrite all e2e tests in rust

* remove python tests

* clippy & fmt

* use cargo tests in ci

* use which to get tmux

* check len

* check all lens

* increase time out and parallelism

* fix no hscroll typo

* better check for print0

* add sleep

* fix execute_0

* update release ci

* try optimizing tests

* better sleep

* Revert "better sleep"

This reverts commit b966367.

* split ci

* cleanup

* test without anchor

* use release-please

---------

Co-authored-by: LoricAndre <[email protected]>
  • Loading branch information
LoricAndre and LoricAndre authored Nov 30, 2024
1 parent d9419c6 commit 7f0dec4
Show file tree
Hide file tree
Showing 21 changed files with 2,245 additions and 1,589 deletions.
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ _check the box if it is not applicable to your changes_
- [ ] I have added unit tests
- [ ] I have added [end-to-end tests](test/test_skim.py)
- [ ] I have linked all related issues or PRs
- [ ] I have re-generated the completions and manpage using `cargo xtask compgen` and `cargo xtask mangen`

## Description of the changes

103 changes: 44 additions & 59 deletions .github/workflows/release.yml → .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- main

permissions:
contents: write
pull-requests: write

env:
RUST_VERSION: 1.82.0
BIN_NAME: "sk"
name: release-please

jobs:
publish-crate:
release_please:
name: release-please
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install correct toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
override: true
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
- name: Publish to crates.io
run: cargo publish -p skim
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- uses: googleapis/release-please-action@v4
with:
release-type: rust
bump-minor-pre-major: true
bump-patch-for-minor-pre-major: true
outputs:
release_created: steps.release.outputs.release_created
tag_name: steps.release.outputs.tag_name
build:
if: ${{ jobs.release_please.outputs.release_created }}
name: Build release binaries
strategy:
matrix:
Expand All @@ -53,12 +46,24 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Clippy
- name: Build
uses: houseabsolute/actions-rust-cross@v0
with:
command: build
target: ${{ matrix.arch }}-${{ matrix.os }}${{ contains(matrix.arch, 'arm') && 'eabi' || '' }}
args: "--release --locked"
- name: Test
uses: houseabsolute/actions-rust-cross@v0
with:
command: test
target: ${{ matrix.arch }}-${{ matrix.os }}${{ contains(matrix.arch, 'arm') && 'eabi' || '' }}
args: "-p skim --release --locked"
- name: E2E
uses: houseabsolute/actions-rust-cross@v0
with:
command: test
target: ${{ matrix.arch }}-${{ matrix.os }}${{ contains(matrix.arch, 'arm') && 'eabi' || '' }}
args: "-p e2e --release --locked -j8"
- name: Create archive
run: |
tar -C target/*/release/ -czvf "skim-${{ matrix.arch }}-${{ matrix.os }}${{ contains(matrix.arch, 'arm') && 'eabi' || '' }}.tgz" "${{ env.BIN_NAME }}"
Expand All @@ -70,6 +75,7 @@ jobs:
retention-days: 1
release-files:
runs-on: ubuntu-22.04
if: ${{ jobs.release_please.outputs.release_created }}
steps:
- name: Checkout Git repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -99,41 +105,20 @@ jobs:
name: files
path: "artifacts/*.tgz"
retention-days: 1
release:
release-artifacts:
runs-on: ubuntu-22.04
needs:
- build
- release-files
- publish-crate
permissions:
contents: write
steps:
- name: Checkout Git repo
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
pattern: "*"
merge-multiple: true
- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
tag: ${{ github.ref_name }}
- name: Create Release
uses: ncipollo/[email protected]
with:
allowUpdates: true
draft: false
makeLatest: true
body: ${{ steps.changelog.outputs.changes }}
artifacts: |
artifacts/**
- name: Push updated CHANGELOG
run: |
git config user.email '[email protected]'
git config user.name 'skim release action'
git add CHANGELOG.md
git commit -m 'update CHANGELOG.md after release ${{ github.ref_name }}'
git push origin main
- uses: actions/download-artifact@v4
with:
path: artifacts
pattern: "*"
merge-multiple: true
- name: Upload Release Artifact
if: ${{ jobs.release_please.outputs.release_created }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ steps.release.outputs.tag_name }} ./artifacts/*.tgz
141 changes: 65 additions & 76 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- master

jobs:
e2e:
unittests:
runs-on: ${{matrix.os}}
strategy:
matrix:
Expand All @@ -23,26 +23,6 @@ jobs:
rust: stable
target: x86_64-apple-darwin
steps:
- name: Install dependencies (for Linux)
run: |
sudo apt-get install zsh
python3 -V
tmux -V
locale
if: runner.os == 'Linux'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
- name: Install dependencies (for MacOS)
run: |
brew install tmux
brew install zsh
python3 -V
tmux -V
locale
if: runner.os == 'macOS'
env:
HOMEBREW_NO_AUTO_UPDATE: 1

- name: Checkout repository
uses: actions/checkout@v2
with:
Expand All @@ -52,18 +32,12 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release
- name: Run Tests
run: tmux new-session -d && python3 test/test_skim.py --verbose
env:
LC_ALL: en_US.UTF-8
TERM: xterm-256color
- name: Run unit tests
run: cargo test -p skim

clippy:
e2e:
runs-on: ${{matrix.os}}
strategy:
matrix:
Expand All @@ -78,54 +52,69 @@ jobs:
rust: stable
target: x86_64-apple-darwin
steps:
- name: Install dependencies (for Linux)
run: |
sudo apt-get install zsh
python3 -V
tmux -V
locale
if: runner.os == 'Linux'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
- name: Install dependencies (for MacOS)
run: |
brew install tmux
brew install zsh
python3 -V
tmux -V
locale
if: runner.os == 'macOS'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
- name: "[linux] Install dependencies"
run: |
sudo apt-get install tmux
tmux -V
locale
if: runner.os == 'Linux'
- name: "[macos] Install dependencies"
run: |
brew install tmux
tmux -V
locale
if: runner.os == 'macOS'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install correct toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Run end-to-end tests
run: |
cargo build --release
tmux new-session -d
cargo test -p e2e -j8
env:
LC_ALL: en_US.UTF-8
TERM: xterm-256color

- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install correct toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
components: clippy
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Clippy
run: cargo clippy
clippy:
runs-on: ${{matrix.os}}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install correct toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: clippy
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Clippy
run: cargo clippy

rustfmt:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
- name: Check formatting
run: |
cargo fmt --all -- --check
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: rustfmt
- name: Check formatting
run: |
cargo fmt --all -- --check
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = [
members = [ "e2e",
"skim",
"xtask"
]
Expand Down
10 changes: 10 additions & 0 deletions e2e/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "e2e"
version = "0.1.0"
edition = "2021"

[dependencies]
rand = "0.8.5"
skim = { path = "../skim" }
tempfile = "3.14.0"
which = "7.0.0"
Loading

0 comments on commit 7f0dec4

Please sign in to comment.