Skip to content

Commit

Permalink
Merge pull request #8 from tbrowder/new-ver
Browse files Browse the repository at this point in the history
New ver
  • Loading branch information
tbrowder authored Oct 3, 2023
2 parents 69551a1 + bac6973 commit 948ce54
Show file tree
Hide file tree
Showing 15 changed files with 152 additions and 92 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Win64

env:
TEST_JOBS: 1

on:
push:
branches:
- '*'
tags-ignore:
- '*'
pull_request:

jobs:
raku:
strategy:
matrix:
os:
- windows-latest
raku-version:
- 'latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: Raku/setup-raku@v1
- name: Install Dependencies
run: |
choco install rakudostar
zef --exclude="z" install --debug --/test --test-depends --deps-only .
- name: Run Tests
run: zef install . --debug
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Revision history for Mi6-Helper

{{$NEXT}}
- More extensive and useful testing in xt
- Clearer code using 'cmd' from module'Pro::Easier' instead of 'raku's 'run'
(thanks, @sdondely!)
- Use @ugexe's solution to replace prove6 (thanks, @ugexe!)

0.9.1 2023-09-09T15:48:27-05:00
- Get Windows testing to be more reliable by using Github workflows
Expand Down
2 changes: 1 addition & 1 deletion META6.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"JSON::Fast",
"App::Mi6:ver<3.0.2+>",
"Text::Utils",
"Ask:ver<0.0.3+>"
"Proc::Easier"
],
"description": "An aid for converting Raku modules to use App::Mi6",
"license": "Artistic-2.0",
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ CREDITS

The very useful Raku modules used herein:

* `App::Mi6` by **github:skaji**
* `App::Mi6` by **zef:skaji**

* `File::Directory::Tree` by **github:labster**

* `File::Temp` by **zef:rbt**

* `Proc::Easier` by **zef:sdondley**

COPYRIGHT AND LICENSE
=====================

Expand Down
23 changes: 18 additions & 5 deletions bin/mi6-helper
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use App::Mi6;
use Text::Utils :normalize-string;
use File::Find;
use JSON::Fast;
use Ask;

if not @*ARGS.elems {
say qq:to/HERE/;
Expand Down Expand Up @@ -49,7 +48,7 @@ if not @*ARGS.elems {
docs - Used with the 'old' mode: uses file 'docs/README.rakudoc'
to produce 'README.md'. Note extra preparation is REQUIRED
by the user before using it.
Debug - For developer use
debug - For developer use
HERE

Expand Down Expand Up @@ -88,7 +87,21 @@ for @*ARGS {
$parent-dir = ~$0;
}
when / ^do[cs]? / { ++$docs }
when / ^de[bug]? / { ++$debug }
when / ^de[bug]? / {
++$debug;
# check for this module's workflows file(s'
say "DEBUG checking for expected workflow(s):";
for "linux", "macos", "windows" -> $OS {
my $path = ".github/workflows/$OS.yml";
if $path {
say " found path '$path'";
}
else {
say " did NOT find '$path'";
}
}
exit;
}
when /^v[ersion]? / {
# check for this module's version
my $ver = get-version;
Expand Down Expand Up @@ -136,7 +149,7 @@ if not $provides.defined {
}
else {
say "FATAL: Unable to find the hidden file '$hidden'.";
my $res = ask "Do you want to continue without it (y/N): ";
my $res = prompt "Do you want to continue without it (y/N): ";
if $res ~~ /:i ^ y/ {
say "Okay, continuing without a 'provides' input...";
}
Expand Down Expand Up @@ -174,7 +187,7 @@ if $dist-ini.IO.f {
say "Danger, file '$dist-ini' exists.";
say "Checking for the 'force' option...";
if $force {
my $ans = ask "Are you sure you want to continue (y/N): ";
my $ans = prompt "Are you sure you want to continue (y/N): ";
if $ans ~~ /:i ^y/ {
say "Continuing with mods...":
}
Expand Down
Empty file modified dev/li.raku
100644 → 100755
Empty file.
8 changes: 8 additions & 0 deletions dev/mi6-new-Foo-Bar/0-README
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,11 @@ Foo-Bar/
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.
# is changed to better English::
This library is free software; you may redistribute it or modify it under the Artistic License 2.0.

# 2023-09-29

.github/workflows
# 1. The single test.yml file has been split into separate OS files:
linux.yml
macos.yml
windows.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: Linux

on:
push:
Expand All @@ -14,19 +14,17 @@ jobs:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
raku-version:
- 'latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: Raku/setup-raku@v1
with:
raku-version: ${{ matrix.raku-version }}
- name: Install Dependencies
run: zef install --/test --test-depends --deps-only .
- name: Install App::Prove6
run: zef install --/test App::Prove6
run: |
zef install --/test --deps-only .
zef install --/test App::Prove6
- name: Run Tests
run: prove6 -I. t
run: prove6 -l t
30 changes: 30 additions & 0 deletions dev/mi6-new-Foo-Bar/Foo-Bar/.github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: MacOS

on:
push:
branches:
- '*'
tags-ignore:
- '*'
pull_request:

jobs:
raku:
strategy:
matrix:
os:
- macos-latest
raku-version:
- 'latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: Raku/setup-raku@v1
with:
raku-version: ${{ matrix.raku-version }}
- name: Install Dependencies
run: |
zef install --/test --deps-only .
zef install --/test App::Prove6
- name: Run Tests
run: prove6 -l t
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
with:
raku-version: ${{ matrix.raku-version }}
- name: Install Dependencies
run: zef --exclude="z" install --debug --/test --test-depends --deps-only .
run: |
choco install rakudostar
zef --exclude="z" install --debug --/test --test-depends --deps-only .
- name: Run Tests
run: raku -I. t/01-load.t
run: zef --debug --/prove --/tap-harness test .
3 changes: 2 additions & 1 deletion docs/README.rakudoc
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ Tom Browder <tbrowder@acm.org>

The very useful Raku modules used herein:

=item C<App::Mi6> by B<github:skaji>
=item C<App::Mi6> by B<zef:skaji>
=item C<File::Directory::Tree> by B<github:labster>
=item C<File::Temp> by B<zef:rbt>
=item C<Proc::Easier> by B<zef:sdondley>

=head1 COPYRIGHT AND LICENSE

Expand Down
96 changes: 28 additions & 68 deletions lib/Mi6/Helper.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ unit class Mi6::Helper;

use App::Mi6;
use JSON::Fast;
use Proc::Easier;

has $.parent-dir = '.';
has $.module-name; #= e.g., 'Foo::Bar'
Expand All @@ -15,22 +16,22 @@ submethod TWEAK {
$!module-base ~~ s:g/'::'/-/;
}

method mi6-new-cmd(:$parent-dir, :$module-name, :$debug) {
method mi6-new-cmd(:$parent-dir!, :$module-name!, :$debug) {
chdir $parent-dir;
run "mi6", 'new', '--zef', $module-name;
cmd "mi6 new --zef $module-name";
}

method git-status {
# branch and working tree status
my $res = run("git", "status", "-b", "-s", :out).out.slurp.chomp
cmd("git status -b -s").out.chomp
}

method git-user-email {
run("git", "config", "--get", "--global", "user.email", :out).out.slurp.chomp
cmd("git config --get --global user.email").out.chomp
}

method git-user-name {
run("git", "config", "--get", "--global", "user.name", :out).out.slurp.chomp
cmd("git config --get --global user.name").out.chomp
}

multi method is-git-repo($dir) {
Expand Down Expand Up @@ -96,7 +97,7 @@ sub mi6-helper-new(:$parent-dir!, :$module-name!, :$provides, :$debug) is export
}
@omodfil.push: $line;
}
# put ramaining content in the README.rakudoc file
# put remaining content in the README.rakudoc file
@idocfil.push($_) for @imodfil;

# treat the README file
Expand All @@ -118,8 +119,8 @@ sub mi6-helper-new(:$parent-dir!, :$module-name!, :$provides, :$debug) is export
}
elsif $line ~~ /^ \h* Copyright/ {
# use copyright symbol
# Copyright © 2021 Tom Browder
# Copyright E<0x00a9> 2021 Tom Browder
# Copyright © 2023 Tom Browder
# Copyright E<0x00a9> 2023 Tom Browder
$line ~~ s/Copyright/;
}
elsif $line ~~ /^ \h* This \h+ library/ {
Expand Down Expand Up @@ -148,63 +149,23 @@ sub mi6-helper-new(:$parent-dir!, :$module-name!, :$provides, :$debug) is export
$fh.say($_) for @omodfil;
$fh.close;

# mod the .github/workflows/test.yml files
my $testfil = "$modpdir/.github/workflows/test.yml";
my @itestfil = $testfil.IO.lines;
# use the Mi6-Helper/.github/workflows/*.yml files as I've updated them
# but they will be in DISTRIBUTION.contents
# note the file handles are CLOSED!!
my $Lstr = $?DISTRIBUTION.content(".github/workflows/linux.yml").open.slurp;
my $Mstr = $?DISTRIBUTION.content(".github/workflows/macos.yml").open.slurp;
my $Wstr = $?DISTRIBUTION.content(".github/workflows/windows.yml").open.slurp;

my $Lfil = "$modpdir/.github/workflows/linux.yml";
my $Wfil = "$modpdir/.github/workflows/windows.yml";
my $Mfil = "$modpdir/.github/workflows/macos.yml";
my $Wfil = "$modpdir/.github/workflows/windows.yml";

my $Lfh = open $Lfil, :w;
my $Wfh = open $Wfil, :w;
my $Mfh = open $Mfil, :w;

my ($L, $W, $M);
while @itestfil.elems {
my $line = @itestfil.shift;
if $line ~~ /'name:' \h+ test / {
$L = $line;
$W = $line;
$M = $line;

$L ~~ s/test/Linux/;
$W ~~ s/test/Win64/;
$M ~~ s/test/MacOS/;

$Lfh.say: $L;
$Wfh.say: $W;
$Mfh.say: $M;
next;
}
if $line ~~ /'-' \h+ [ubuntu|windows|macos] '-' latest / {
# need to replace three lines with one
@itestfil.shift;
@itestfil.shift;

$L = $line;
$W = $line;
$M = $line;

$L ~~ s/[ubuntu|windows|macos]/ubuntu/;
$W ~~ s/[ubuntu|windows|macos]/windows/;
$M ~~ s/[ubuntu|windows|macos]/macos/;

$Lfh.say: $L;
$Wfh.say: $W;
$Mfh.say: $M;
next;
}
$Lfh.say: $line;
$Wfh.say: $line;
$Mfh.say: $line;
}
$Lfh.close;
$Wfh.close;
$Mfh.close;
unlink $testfil; # don't need the old one
spurt $Lfil, $Lstr;
spurt $Mfil, $Mstr;
spurt $Wfil, $Wstr;

# mod the dist.ini file. add ALL optional sections recognized by App::Mi6

# mod the dist.ini file. add ALL optional sections recognized byApp::Mi6
my $distfil = "$modpdir/dist.ini";
my @idistfil = $distfil.IO.lines;
my @odistfil;
Expand Down Expand Up @@ -286,10 +247,9 @@ sub mi6-helper-new(:$parent-dir!, :$module-name!, :$provides, :$debug) is export
@odistfil.push: $str;
}

note "Found $nsections sections" if $debug;
note "DEBUG: Found $nsections sections" if $debug;
$fh = open $distfil, :w;
$fh.say($_) for @odistfil;

$fh.close;

# mod the META6.json file
Expand Down Expand Up @@ -318,14 +278,14 @@ sub mi6-helper-new(:$parent-dir!, :$module-name!, :$provides, :$debug) is export
# need to change dirs
note "$modpdir IS a git repo" if $debug;
temp $*CWD = $modpdir.IO;
run "git", "add", ".github/workflows/linux.yml";
run "git", "add", ".github/workflows/windows.yml";
run "git", "add", ".github/workflows/macos.yml";
run "git", "add", "docs/README.rakudoc";
cmd "git add '.github/workflows/linux.yml'";
cmd "git add '.github/workflows/windows.yml'";
cmd "git add '.github/workflows/macos.yml'";
cmd "git add docs/README.rakudoc";

# finish the repo to be ready for pushing
run "mi6", "build";
run "git", "commit", "-a", "-m'initial commit'";
cmd "mi6 build";
cmd "git commit -a -m'initial commit'";
}

} # sub mi6-helper-new
Expand Down
1 change: 1 addition & 0 deletions xt/01-check-git-repo.t → xt/1-check-git-repo.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use Test;
use Mi6::Helper;
use App::Mi6;
use Temp::Path;
use Proc::Easier;

# Create some test repos:
# 1. An Mi6 dir with three types of files in addition to a
Expand Down
Loading

0 comments on commit 948ce54

Please sign in to comment.