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

feat: create ci workflow on lake new/init #4608

Merged
merged 7 commits into from
Jul 25, 2024
Merged
Changes from 3 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
29 changes: 29 additions & 0 deletions src/lake/Lake/CLI/Init.lean
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ def mathToolchainBlobUrl : String :=
def mathToolchainUrl : String :=
"https://github.com/leanprover-community/mathlib4/blob/master/lean-toolchain"

def leanActionWorkflowContents :=
"name: Lean Action CI

on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: leanprover/lean-action@v1
"

/-- Lake package template identifier. -/
inductive InitTemplate
Expand Down Expand Up @@ -287,6 +303,17 @@ def validatePkgName (pkgName : String) : LogIO PUnit := do
if pkgName.toLower ∈ ["init", "lean", "lake", "main"] then
error "reserved package name"

def createLeanActionWorkflow (dir : FilePath) : LogIO PUnit := do
logInfo "creating lean-action CI workflow"
let workflowDir := dir / ".github" / "workflows"
let workflowFile := workflowDir / "lean_action_ci.yml"
if (← workflowFile.pathExists) then
logWarning "lean-action CI workflow already exists"
austinletson marked this conversation as resolved.
Show resolved Hide resolved
return
IO.FS.createDirAll workflowDir
IO.FS.writeFile workflowFile leanActionWorkflowContents
logInfo s!"created lean-action CI workflow at '{workflowFile}'"
austinletson marked this conversation as resolved.
Show resolved Hide resolved

def init (name : String) (tmp : InitTemplate) (lang : ConfigLang) (env : Lake.Env) (cwd : FilePath := ".") : LogIO PUnit := do
let name ← id do
if name == "." then
Expand All @@ -300,6 +327,7 @@ def init (name : String) (tmp : InitTemplate) (lang : ConfigLang) (env : Lake.En
validatePkgName name
IO.FS.createDirAll cwd
initPkg cwd (stringToLegalOrSimpleName name) tmp lang env
createLeanActionWorkflow cwd
tydeu marked this conversation as resolved.
Show resolved Hide resolved

def new (name : String) (tmp : InitTemplate) (lang : ConfigLang) (env : Lake.Env) (cwd : FilePath := ".") : LogIO PUnit := do
let name := name.trim
Expand All @@ -309,3 +337,4 @@ def new (name : String) (tmp : InitTemplate) (lang : ConfigLang) (env : Lake.En
let dir := cwd / dirName
IO.FS.createDirAll dir
initPkg dir name tmp lang env
createLeanActionWorkflow dir
tydeu marked this conversation as resolved.
Show resolved Hide resolved
Loading