Skip to content

Commit

Permalink
chore(ci): add ci for test and release
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowApex committed Feb 14, 2024
1 parent 6f3f9a1 commit 5f333cc
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 8 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Build and publish a release of Gamescope DBus using semantic-release whenever
# changes are merged into main.
name: "🎉 Release"

on:
push:
branches:
- main
- v0.x
- v1.x
paths-ignore:
- README.md
- "docs/**"

# Jobs to run
jobs:
release:
name: Publish
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: "20"

- name: Install Dependencies
run: npm install @semantic-release/exec @google/semantic-release-replace-plugin @semantic-release/git

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make sem-release
13 changes: 13 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: 🪲 Test

on: [push, pull_request]

jobs:
run-tests:
name: Run tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- run: |
make in-docker TARGET='test'
52 changes: 52 additions & 0 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Semantic Release Configuration
# https://semantic-release.gitbook.io/semantic-release/usage/configuration

# Any merges into branches that match these patterns will trigger a release.
branches:
- name: main
#- name: 'v+([0-9])?(.{+([0-9]),x}).x'

# These plugins will run when a release is triggered. They will analyze commit
# messages to determine what kind of release this is and publish a new release.
plugins:
# Analyze commit messages to determine next version
- "@semantic-release/commit-analyzer"

# Generate release notes
- "@semantic-release/release-notes-generator"

# Replace version strings in the project. The 'git' plugin is needed to
# commit the version strings to the repository.
- - "@google/semantic-release-replace-plugin"
- replacements:
- files:
- Cargo.toml
from: '^version = .*"$'
to: 'version = "${nextRelease.version}"'
#results:
# - file: Cargo.toml
# hasChanged: true
# numMatches: 1
# numReplacements: 1
#countMatches: true

# Commit the following changes to git after other plugins have run
- - "@semantic-release/git"
- assets:
- Cargo.toml
- Cargo.lock

# Execute commands to build the project
- - "@semantic-release/exec"
- shell: true
prepareCmd: "make in-docker TARGET='dist'"

# Publish artifacts as a GitHub release
- - "@semantic-release/github"
- assets:
- path: dist/inputplumber-*.rpm
- path: dist/inputplumber-*.rpm.sha256.txt
- path: dist/inputplumber.tar.gz
- path: dist/inputplumber.tar.gz.sha256.txt
- path: dist/inputplumber.raw
- path: dist/inputplumber.raw.sha256.txt
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,24 @@ dist/$(NAME).raw: dist/$(NAME).tar.gz
mv $(CACHE_DIR)/$(NAME).raw $@
cd dist && sha256sum $(NAME).raw > $(NAME).raw.sha256.txt

##@ Deployment
# Refer to .releaserc.yaml for release configuration
.PHONY: sem-release
sem-release: ## Publish a release with semantic release
npx semantic-release

# E.g. make in-docker TARGET=build
.PHONY: in-docker
in-docker:
@# Run the given make target inside Docker
docker run --rm \
-v $(PWD):/src \
--workdir /src \
-e HOME=/home/build \
--user $(shell id -u):$(shell id -g) \
$(IMAGE_NAME):$(IMAGE_TAG) \
make $(TARGET)

##@ Deployment

.PHONY: deploy
deploy: deploy-ext ## Build and deploy to a remote device
Expand All @@ -148,3 +164,4 @@ deploy-ext: dist-ext ## Build and deploy systemd extension to a remote device
scp dist/$(NAME).raw $(SSH_USER)@$(SSH_HOST):~/.var/lib/extensions
ssh -t $(SSH_USER)@$(SSH_HOST) sudo systemd-sysext refresh
ssh $(SSH_USER)@$(SSH_HOST) systemd-sysext status

15 changes: 8 additions & 7 deletions src/udev/device_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ use crate::udev::get_device;

#[tokio::test]
async fn test_get_device() -> Result<(), Box<dyn Error>> {
let path = "/dev/input/event21";
let device = get_device(path.to_string()).await?;
println!("Parsed device: {:?}", device);
println!("Parent: {:?}", device.get_parent());
println!("Parent name: {:?}", device.get_parent_device_name());
println!("Vendor ID: {:?}", device.get_vendor_id());
println!("Product ID: {:?}", device.get_product_id());
let path = "/dev/hidraw0";
if let Ok(device) = get_device(path.to_string()).await {
println!("Parsed device: {:?}", device);
println!("Parent: {:?}", device.get_parent());
println!("Parent name: {:?}", device.get_parent_device_name());
println!("Vendor ID: {:?}", device.get_vendor_id());
println!("Product ID: {:?}", device.get_product_id());
}

Ok(())
}

0 comments on commit 5f333cc

Please sign in to comment.