Skip to content

Commit

Permalink
add default workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlan404 committed Dec 21, 2023
1 parent 39b2700 commit 23d6647
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 15 deletions.
65 changes: 62 additions & 3 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mcman"
version = "0.4.2"
version = "0.4.3"
edition = "2021"
repository = "https://github.com/ParadigmMC/mcman"
homepage = "https://paradigmmc.github.io/mcman/"
Expand Down Expand Up @@ -55,3 +55,4 @@ base16ct = { version = "0.2", features = ["alloc"] }
digest = "0.10"
opener = "0.6"
confique = { version = "0.2.5", default-features = false, features = ["toml"] }
rayon = "1.8.0"
10 changes: 0 additions & 10 deletions res/default_gitignore

This file was deleted.

31 changes: 31 additions & 0 deletions res/workflows/packwiz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Export Packwiz

on:
push:
branches:
- main

jobs:
packwiz-export:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v2

- name: Install mcman
run: |
wget https://github.com/ParadigmMC/mcman/releases/latest/download/mcman
sudo mv ./mcman /usr/bin/
sudo chmod +x /usr/bin/mcman
- name: Run mcman export packwiz
run: mcman export packwiz
env:
MODPACK_VERSION: ${{ github.sha }}

- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update packwiz pack
53 changes: 53 additions & 0 deletions res/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test server

on:
push:
branches: main

jobs:
test:
env:
upload_to_mclogs: true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Cache
id: cache
uses: actions/cache@v3
with:
key: mcman-build-${{ hashFiles('server.toml') }}
path: |
./server
~/.cache/mcman
restore-keys: |
mcman-build-${{ hashFiles('server.toml') }}
mcman-build-
mcman-
- name: Install mcman
run: |
wget https://github.com/ParadigmMC/mcman/releases/latest/download/mcman
sudo mv ./mcman /usr/bin/
sudo chmod +x /usr/bin/mcman
- name: Test the server
id: test
run: |
mcman run --test
- name: Archive log
uses: actions/upload-artifact@v3
with:
name: latest.log
path: |
server/logs/latest.log
- name: Archive crash reports
uses: actions/upload-artifact@v3
if: steps.test.outcome == 'failure'
with:
name: crash
path: |
server/crash-reports/*
8 changes: 8 additions & 0 deletions src/commands/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@ use crate::app::App;

mod docker;
mod gitignore;
mod workflow_test;
mod workflow_packwiz;

#[derive(clap::Subcommand, Clone, Copy)]
pub enum Commands {
/// Modify the gitignore
Gitignore,
/// Write the default Dockerfile and .dockerignore
Docker,
/// github workflow: test the server
Test,
/// github workflow: export packwiz automatically
Packwiz,
}

pub fn run(app: &App, commands: Commands) -> Result<()> {
match commands {
Commands::Gitignore => gitignore::run(app),
Commands::Docker => docker::run(app),
Commands::Packwiz => workflow_packwiz::run(app),
Commands::Test => workflow_test::run(app),
}
}
16 changes: 16 additions & 0 deletions src/commands/env/workflow_packwiz.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use std::{path::Path, io::Write};

use anyhow::Result;
use std::fs::File;

use crate::{util::env::get_git_root, app::App};

pub fn run(app: &App) -> Result<()> {
let path = Path::new(&get_git_root()?.unwrap_or(".".to_owned())).join(".github").join("workflows");

let mut f = File::create(path.join("packwiz.yml"))?;
f.write_all(include_bytes!("../../../res/workflows/packwiz.yml"))?;
app.success("packwiz.yml workflow created");

Ok(())
}
16 changes: 16 additions & 0 deletions src/commands/env/workflow_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use std::{path::Path, io::Write};

use anyhow::Result;
use std::fs::File;

use crate::{util::env::get_git_root, app::App};

pub fn run(app: &App) -> Result<()> {
let path = Path::new(&get_git_root()?.unwrap_or(".".to_owned())).join(".github").join("workflows");

let mut f = File::create(path.join("test.yml"))?;
f.write_all(include_bytes!("../../../res/workflows/test.yml"))?;
app.success("test.yml workflow created");

Ok(())
}
2 changes: 1 addition & 1 deletion src/util/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn write_gitignore() -> Result<PathBuf> {
pub fn write_gitattributes() -> Result<PathBuf> {
let root = get_git_root()?.ok_or(anyhow!("cant get repo root"))?;

let gitattributes_path = Path::new(&root).join(".gitattibutes");
let gitattributes_path = Path::new(&root).join(".gitattributes");

let contents = fs::read_to_string(&gitattributes_path).unwrap_or_default();

Expand Down

0 comments on commit 23d6647

Please sign in to comment.