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

Enable windows in github actions #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .ameba.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Performance/MinMaxAfterMap:
Enabled: false
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
lint: true
- os: windows-latest

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

env:
TERM: xterm-256color
Expand All @@ -23,12 +28,14 @@ jobs:
uses: actions/checkout@v2

- name: Check formatting
if: ${{ matrix.lint }}
run: crystal tool format --check

- name: Install dependencies
run: shards install

- name: Run linter
if: ${{ matrix.lint }}
run: ./bin/ameba

- name: Setup environment
Expand Down
16 changes: 8 additions & 8 deletions examples/sam.cr
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ end
namespace "db" do
namespace "schema" do
desc "just test"
task "load" do |t, args|
task "load" do |task, args|
puts args["f1"]
t.invoke("1")
t.invoke("schema:1")
t.invoke("db:migrate")
t.invoke("db:db:migrate")
t.invoke("db:ping")
t.invoke("din:dong")
task.invoke("1")
task.invoke("schema:1")
task.invoke("db:migrate")
task.invoke("db:db:migrate")
task.invoke("db:ping")
task.invoke("din:dong")
puts "------"
t.invoke("2", {"f2" => 1})
task.invoke("2", {"f2" => 1})
end

desc "1"
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license: MIT
development_dependencies:
ameba:
github: crystal-ameba/ameba
version: "= 1.4.3"
version: "= 1.6.1"

scripts:
postinstall: "false | [ -f ../../sam.cr ] && true || cp -i examples/sam.template ../../sam.cr 2>/dev/null"
6 changes: 4 additions & 2 deletions spec/sam_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require "./spec_helper"

executable = "crystal #{File.join("examples", "sam.cr")}"

describe Sam do
describe ".namespace" do
pending "add" do
Expand Down Expand Up @@ -27,7 +29,7 @@ describe Sam do

describe ".help" do
it "with multiple tasks" do
res = execute("crystal examples/sam.cr", ["db:with_argument", "f1=a", "@", "db:ping"])
res = execute(executable, ["db:with_argument", "f1=a", "@", "db:ping"])
res[1].should eq(<<-TEXT)
a
ping
Expand All @@ -44,7 +46,7 @@ describe Sam do
end

it "without a specified task and without a default task defined" do
res = execute("crystal examples/sam.cr", %w[])
res = execute(executable, %w[])
res[1].should eq(<<-TEXT)
Hm, nothing to do...

Expand Down
29 changes: 17 additions & 12 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ end
def execute(command, options)
io = IO::Memory.new

status = Process.run("#{command} \"${@}\"", options, shell: true, output: io, error: io).exit_status
status =
{% if flag?(:win32) %}
Process.run("#{command} \"${@}\"", options, output: io, error: io)
{% else %}
Process.run("#{command} \"${@}\"", options, shell: true, output: io, error: io)
{% end %}.exit_status
{status, io.to_s}
end

Expand All @@ -40,16 +45,16 @@ end

namespace "db" do
namespace "schema" do
task "load" do |t, args|
task "load" do |task, args|
puts args["f1"]
t.invoke("1")
t.invoke("schema:1")
t.invoke("db:migrate")
t.invoke("db:db:migrate")
t.invoke("db:ping")
t.invoke("din:dong")
t.invoke("schema")
Container.add(t.path)
task.invoke("1")
task.invoke("schema:1")
task.invoke("db:migrate")
task.invoke("db:db:migrate")
task.invoke("db:ping")
task.invoke("din:dong")
task.invoke("schema")
Container.add(task.path)
end

task "1" do
Expand All @@ -58,9 +63,9 @@ namespace "db" do
end
end

task "with_argument" do |t, args|
task "with_argument" do |task, args|
puts args["f1"]
Container.add(t.path)
Container.add(task.path)
end

task "schema" do
Expand Down
4 changes: 2 additions & 2 deletions spec/task_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe Sam::Task do
it "accepts arg object" do
count = 0
namespace.task("t1") { |_, args| count += args["count"].as(Int32) }
namespace.task("t2") { |t, args| t.invoke("t1", args) }.call(Sam::Args.new({"count" => 2}))
namespace.task("t2") { |task, args| task.invoke("t1", args) }.call(Sam::Args.new({"count" => 2}))
count.should eq(2)
end

Expand Down Expand Up @@ -160,7 +160,7 @@ describe Sam::Task do
it "accepts arg object" do
count = 0
namespace.task("t1") { |_, args| count += args["count"].as(Int32) }
namespace.task("t2") { |t, args| t.execute("t1", args) }.call(Sam::Args.new({"count" => 2}))
namespace.task("t2") { |task, args| task.execute("t1", args) }.call(Sam::Args.new({"count" => 2}))
count.should eq(2)
end

Expand Down
Loading