Skip to content
Closed
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
24 changes: 24 additions & 0 deletions .github/workflows/pony-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: pony-lint

on:
pull_request:
paths:
- '**/*.pony'

concurrency:
group: pony-lint-${{ github.ref }}
cancel-in-progress: true

permissions:
packages: read

jobs:
pony-lint:
name: Lint Pony source
runs-on: ubuntu-latest
container:
image: ghcr.io/ponylang/shared-docker-ci-standard-builder:nightly
steps:
- uses: actions/checkout@v6.0.2
- name: Lint
run: make lint
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ else
PONYC = $(COMPILE_WITH) --debug
endif

ifeq (,$(filter $(MAKECMDGOALS),clean docs realclean TAGS))
LINT_WITH := corral run -- pony-lint

ifeq (,$(filter $(MAKECMDGOALS),clean docs lint realclean TAGS))
ifeq ($(ssl), 3.0.x)
SSL = -Dopenssl_3.0.x
else ifeq ($(ssl), 1.1.x)
Expand Down Expand Up @@ -85,4 +87,8 @@ all: test
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)

.PHONY: all examples _build_examples clean fetch TAGS test test-one
lint:
$(GET_DEPENDENCIES_WITH)
$(LINT_WITH) .

.PHONY: all examples _build_examples clean fetch lint TAGS test test-one
3 changes: 3 additions & 0 deletions examples/create-gist-oo/create_gist_oo.pony
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Example program: create-gist-oo.
"""
31 changes: 19 additions & 12 deletions examples/create-gist-oo/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,32 @@ actor Main
try
// ----- CLI setup
let cs =
CommandSpec.leaf("create-gist-oo",
CommandSpec.leaf(
"create-gist-oo",
"Create a new gist with a single file",
[
OptionSpec.string("filename", "Name of the file to create")
OptionSpec.string("content", "Content of the file")
OptionSpec.string("description",
OptionSpec.string(
"description",
"Description of the gist"
where default' = "")
OptionSpec.bool("public",
OptionSpec.bool(
"public",
"Whether the gist should be public"
where default' = false)
OptionSpec.string("token", "GitHub personal access token")
]
)? .> add_help()?

let cmd = match \exhaustive\ CommandParser(cs).parse(env.args, env.vars)
| let c: Command =>
let cmd =
match \exhaustive\ CommandParser(cs).parse(env.args, env.vars)
| let c: Command =>
c
| let ch: CommandHelp =>
| let ch: CommandHelp =>
ch.print_help(env.out)
return
| let se: SyntaxError =>
| let se: SyntaxError =>
env.err.print(se.string())
env.exitcode(1)
return
Expand All @@ -45,11 +49,11 @@ actor Main
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

let files = recover val
let f = Array[(String, String)]
f.push((filename, content))
f
end
let files =
recover val
Array[(String, String)]
.> push((filename, content))
end

let desc: (String | None) =
if description.size() > 0 then description else None end
Expand All @@ -61,6 +65,9 @@ actor Main
end

primitive PrintGist
"""
Prints gist creation results to the given output stream.
"""
fun apply(out: OutStream, g: GistOrError) =>
match \exhaustive\ g
| let gist: Gist =>
Expand Down
3 changes: 3 additions & 0 deletions examples/create-gist/create_gist.pony
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Example program: create-gist.
"""
31 changes: 19 additions & 12 deletions examples/create-gist/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,32 @@ actor Main
try
// ----- CLI setup
let cs =
CommandSpec.leaf("create-gist",
CommandSpec.leaf(
"create-gist",
"Create a new gist with a single file",
[
OptionSpec.string("filename", "Name of the file to create")
OptionSpec.string("content", "Content of the file")
OptionSpec.string("description",
OptionSpec.string(
"description",
"Description of the gist"
where default' = "")
OptionSpec.bool("public",
OptionSpec.bool(
"public",
"Whether the gist should be public"
where default' = false)
OptionSpec.string("token", "GitHub personal access token")
]
)? .> add_help()?

let cmd = match \exhaustive\ CommandParser(cs).parse(env.args, env.vars)
| let c: Command =>
let cmd =
match \exhaustive\ CommandParser(cs).parse(env.args, env.vars)
| let c: Command =>
c
| let ch: CommandHelp =>
| let ch: CommandHelp =>
ch.print_help(env.out)
return
| let se: SyntaxError =>
| let se: SyntaxError =>
env.err.print(se.string())
env.exitcode(1)
return
Expand All @@ -45,11 +49,11 @@ actor Main
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

let files = recover val
let f = Array[(String, String)]
f.push((filename, content))
f
end
let files =
recover val
Array[(String, String)]
.> push((filename, content))
end

let desc: (String | None) =
if description.size() > 0 then description else None end
Expand All @@ -61,6 +65,9 @@ actor Main
end

primitive PrintGist
"""
Prints gist creation results to the given output stream.
"""
fun apply(out: OutStream, g: GistOrError) =>
match \exhaustive\ g
| let gist: Gist =>
Expand Down
3 changes: 3 additions & 0 deletions examples/create-issue-comment-oo/create_issue_comment_oo.pony
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Example program: create-issue-comment-oo.
"""
35 changes: 23 additions & 12 deletions examples/create-issue-comment-oo/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ actor Main
try
// ----- CLI setup
let cs =
CommandSpec.leaf("create-issue-comment-oo",
CommandSpec.leaf(
"create-issue-comment-oo",
"Create a comment on a GitHub issue",
[
OptionSpec.string("owner", "Owner of the repository the issue is in")
OptionSpec.string("repo", "Name of the repository the issue is in")
OptionSpec.string("owner", "Repository owner")
OptionSpec.string("repo", "Repository name")
OptionSpec.i64("issue", "Issue number")
OptionSpec.string("comment", "Comment to add to the issue")
OptionSpec.string("token", "GitHub personal access token")
]
)? .> add_help()?

let cmd = match \exhaustive\ CommandParser(cs).parse(env.args, env.vars)
| let c: Command =>
let cmd =
match \exhaustive\ CommandParser(cs).parse(env.args, env.vars)
| let c: Command =>
c
| let ch: CommandHelp =>
| let ch: CommandHelp =>
ch.print_help(env.out)
return
| let se: SyntaxError =>
| let se: SyntaxError =>
env.err.print(se.string())
env.exitcode(1)
return
Expand All @@ -43,32 +45,41 @@ actor Main
let creds = Credentials(auth, token)

GitHub(creds).get_repo(owner, repo)
.flatten_next[IssueOrError](RetrieveIssue~apply(issue))
.flatten_next[IssueCommentOrError](CreateComment~apply(comment))
.next[None](PrintComment~apply(env.out))
.flatten_next[IssueOrError](RetrieveIssue~apply(issue))
.flatten_next[IssueCommentOrError](CreateComment~apply(comment))
.next[None](PrintComment~apply(env.out))
else
env.out.print("Something went wrong")
end

primitive RetrieveIssue
"""
Retrieves an issue from the repository.
"""
fun apply(number: I64, r: RepositoryOrError): Promise[IssueOrError] =>
match \exhaustive\ r
| let repo: Repository =>
repo.get_issue(number)
| let e: RequestError =>
Promise[IssueOrError].>apply(e)
Promise[IssueOrError] .> apply(e)
end

primitive CreateComment
"""
Creates a comment on an issue.
"""
fun apply(body: String, i: IssueOrError): Promise[IssueCommentOrError] =>
match \exhaustive\ i
| let issue: Issue =>
issue.create_comment(body)
| let e: RequestError =>
Promise[IssueCommentOrError].>apply(e)
Promise[IssueCommentOrError] .> apply(e)
end

primitive PrintComment
"""
Prints issue comment results to the given output stream.
"""
fun apply(out: OutStream, c: IssueCommentOrError) =>
match \exhaustive\ c
| let comment: IssueComment =>
Expand Down
3 changes: 3 additions & 0 deletions examples/create-issue-comment/create_issue_comment.pony
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Example program: create-issue-comment.
"""
19 changes: 12 additions & 7 deletions examples/create-issue-comment/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@ actor Main
try
// ----- CLI setup
let cs =
CommandSpec.leaf("create-issue-comment",
CommandSpec.leaf(
"create-issue-comment",
"Create a comment on a GitHub issue",
[
OptionSpec.string("owner", "Owner of the repository the issue is in")
OptionSpec.string("repo", "Name of the repository the issue is in")
OptionSpec.string("owner", "Repository owner")
OptionSpec.string("repo", "Repository name")
OptionSpec.i64("issue", "Issue number")
OptionSpec.string("comment", "Comment to add to the issue")
OptionSpec.string("token", "GitHub personal access token")
]
)? .> add_help()?

let cmd = match \exhaustive\ CommandParser(cs).parse(env.args, env.vars)
| let c: Command =>
let cmd =
match \exhaustive\ CommandParser(cs).parse(env.args, env.vars)
| let c: Command =>
c
| let ch: CommandHelp =>
| let ch: CommandHelp =>
ch.print_help(env.out)
return
| let se: SyntaxError =>
| let se: SyntaxError =>
env.err.print(se.string())
env.exitcode(1)
return
Expand All @@ -48,6 +50,9 @@ actor Main
end

primitive PrintComment
"""
Prints issue comment results to the given output stream.
"""
fun apply(out: OutStream, c: IssueCommentOrError) =>
match \exhaustive\ c
| let comment: IssueComment =>
Expand Down
3 changes: 3 additions & 0 deletions examples/create-label-oo/create_label_oo.pony
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Example program: create-label-oo.
"""
20 changes: 14 additions & 6 deletions examples/create-label-oo/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ actor Main
try
// ----- CLI setup
let cs =
CommandSpec.leaf("create-label-oo",
CommandSpec.leaf(
"create-label-oo",
"Create a new label",
[
OptionSpec.string(
Expand All @@ -23,13 +24,14 @@ actor Main
]
)? .> add_help()?

let cmd = match \exhaustive\ CommandParser(cs).parse(env.args, env.vars)
| let c: Command =>
let cmd =
match \exhaustive\ CommandParser(cs).parse(env.args, env.vars)
| let c: Command =>
c
| let ch: CommandHelp =>
| let ch: CommandHelp =>
ch.print_help(env.out)
return
| let se: SyntaxError =>
| let se: SyntaxError =>
env.err.print(se.string())
env.exitcode(1)
return
Expand All @@ -54,6 +56,9 @@ actor Main
end

primitive MakeLabel
"""
Creates a label on the repository.
"""
fun apply(name: String,
color: String,
description: String,
Expand All @@ -63,10 +68,13 @@ primitive MakeLabel
| let repo: Repository =>
repo.create_label(name, color, description)
| let e: RequestError =>
Promise[LabelOrError].>apply(e)
Promise[LabelOrError] .> apply(e)
end

primitive PrintLabel
"""
Prints label results to the given output stream.
"""
fun apply(out: OutStream, l: LabelOrError) =>
match \exhaustive\ l
| let label: Label =>
Expand Down
3 changes: 3 additions & 0 deletions examples/create-label/create_label.pony
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Example program: create-label.
"""
Loading
Loading