Skip to content

Commit

Permalink
Release 2.0.1 'RaCoCo as library and configurable cache directory'
Browse files Browse the repository at this point in the history
  • Loading branch information
atroxaper committed Feb 24, 2023
2 parents e482b55 + 82f4cb2 commit ac7b983
Show file tree
Hide file tree
Showing 171 changed files with 1,355 additions and 823 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- 'latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Raku/setup-raku@v1
with:
raku-version: ${{ matrix.raku-version }}
Expand All @@ -25,7 +25,7 @@ jobs:
- name: Install App::Prove6
run: zef install --/test App::Prove6
- name: Install App::Racoco::Report::ReporterCoveralls
run: zef install --/test App::Racoco::Report::ReporterCoveralls
run: zef install --/test App::Racoco::Report::ReporterCoveralls:auth<zef:atroxaper>
- name: Run RaCoCo
run: raku -Ilib bin/racoco --reporter=coveralls --exec='prove6 t xt'
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- 'latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Raku/setup-raku@v1
with:
raku-version: ${{ matrix.raku-version }}
Expand All @@ -25,4 +25,4 @@ jobs:
- name: Install App::Prove6
run: zef install --/test App::Prove6
- name: Run Tests
run: prove6 t xt
run: prove6 t xt
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- 'latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Raku/setup-raku@v1
with:
raku-version: ${{ matrix.raku-version }}
Expand All @@ -27,4 +27,4 @@ jobs:
- name: Install App::Prove6
run: zef install --/test App::Prove6
- name: Run Tests
run: prove6 t xt
run: prove6 t xt
6 changes: 3 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
os:
- windows-latest
raku-version:
- 'latest'
- '2022.07'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Raku/setup-raku@v1
with:
raku-version: ${{ matrix.raku-version }}
Expand All @@ -25,4 +25,4 @@ jobs:
- name: Install App::Prove6
run: zef install --/test App::Prove6
- name: Run Tests
run: prove6 t xt
run: prove6 t xt
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ t/lib/.precomp/**
**/.idea/**
**/*.iml
**/.DS_Store
.racoco/**
.racoco/**
t-resources/exam/**
9 changes: 8 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Version history:

2.0.1 2023-02-24 'RaCoCo as library and configurable cache directory'
- Add '--cache-dir' option. With the option we can point to directory to store index, reports, precomp files and so on for racoco. It is possible to have the directory outside of a project
- Encapsulate racoco login in one class App::Racoco. With that we can use RaCoCo as library in any Raku code
- Refactor Cli - stay only work with options in it
- Create Paths class to encapsulate logic with directories and files for a project. Paths can replace :$lib parameter through all the code. The change force to bump API version
- Create cascade Configuration system. The system replaced Properties class. The change force to bump API version

1.6.0 2022-07-02 'No precompilation modules and -I'
- Add support for project modules with 'no precompilation' pragma. Such project will have inaccurate results.
- Add '-I' option key as a short-cut for --exec='prove6 -I.'
Expand Down Expand Up @@ -36,4 +43,4 @@ Version history:
- Update README

1.3.1 2021-03-14 'The first public release'
- Production ready code coverage tool
- Production ready code coverage tool
8 changes: 5 additions & 3 deletions META6.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "App::RaCoCo",
"description": "Raku Code Coverage tool.",
"version": "1.6.0",
"version": "2.0.1",
"perl": "6.d",
"authors": [
"Mikhail Khorkov"
Expand All @@ -13,8 +13,10 @@
"App::Prove6"
],
"provides": {
"App::Racoco": "lib/App/Racoco.rakumod",
"App::Racoco::Cli": "lib/App/Racoco/Cli.rakumod",
"App::Racoco::ConfigFile": "lib/App/Racoco/ConfigFile.rakumod",
"App::Racoco::Configuration": "lib/App/Racoco/Configuration.rakumod",
"App::Racoco::Coverable::Coverable": "lib/App/Racoco/Coverable/Coverable.rakumod",
"App::Racoco::Coverable::CoverableIndex": "lib/App/Racoco/Coverable/CoverableIndex.rakumod",
"App::Racoco::Coverable::CoverableLinesSupplier": "lib/App/Racoco/Coverable/CoverableLinesSupplier.rakumod",
Expand All @@ -29,12 +31,12 @@
"App::Racoco::ModuleNames": "lib/App/Racoco/ModuleNames.rakumod",
"App::Racoco::Paths": "lib/App/Racoco/Paths.rakumod",
"App::Racoco::ProjectName": "lib/App/Racoco/ProjectName.rakumod",
"App::Racoco::Properties": "lib/App/Racoco/Properties.rakumod",
"App::Racoco::Report::Data": "lib/App/Racoco/Report/Data.rakumod",
"App::Racoco::Report::DataPart": "lib/App/Racoco/Report/DataPart.rakumod",
"App::Racoco::Report::Reporter": "lib/App/Racoco/Report/Reporter.rakumod",
"App::Racoco::Report::ReporterHtml": "lib/App/Racoco/Report/ReporterHtml.rakumod",
"App::Racoco::Report::ReporterHtmlColorBlind": "lib/App/Racoco/Report/ReporterHtmlColorBlind.rakumod",
"App::Racoco::Report::ReporterSimple": "lib/App/Racoco/Report/ReporterSimple.rakumod",
"App::Racoco::RunProc": "lib/App/Racoco/RunProc.rakumod",
"App::Racoco::Sha": "lib/App/Racoco/Sha.rakumod",
"App::Racoco::X": "lib/App/Racoco/X.rakumod"
Expand All @@ -48,6 +50,6 @@
"COVERAGE",
"RACOCO"
],
"api": "1",
"api": "2",
"source-url": "https://github.com/atroxaper/raku-RaCoCo.git"
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ You may specify the following options:

* **--fail-level** - integer number - if the coverage level will be less than it then `racoco` will exit with a non-zero exit code;

* **--cache-dir** - path to directory where project related files racoco will be stored (`'./.racoco'` by default);

* **--silent** - hide test result output;

* **--append** - append the previous run result to the new one;
Expand Down Expand Up @@ -102,6 +104,6 @@ Sources can be found at: [github](https://github.com/atroxaper/raku-RaCoCo). The

# COPYRIGHT AND LICENSE

Copyright 2022 Mikhail Khorkov
Copyright 2023 Mikhail Khorkov

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.
8 changes: 4 additions & 4 deletions Roadmap.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Backlog:
* Convert project from a tool to tool&library. Make it possible to calculate a coverage from the Raku code.
* Centrally check lib (and other paths) to be absolute.
* Add :create adverb to all Paths subs.
* Refactory CLI
* ~~Centrally check lib (and other paths) to be absolute.~~
* ~~Add :create adverb to all Paths subs.~~ (not necessary)
* ~~Convert project from a tool to tool&library. Make it possible to calculate a coverage from the Raku code.~~
* ~~Refactor CLI~~
* Create reporter for LCOV format file. It will provide a possibility to use coveralls-github-action GitHub Action.
* Improve ConfigFile grammar and tests.
98 changes: 98 additions & 0 deletions lib/App/Racoco.rakumod
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
use App::Racoco::Configuration;
use App::Racoco::RunProc;
use App::Racoco::Paths;
use App::Racoco::CoveredLinesCollector;
use App::Racoco::Coverable::Precomp::PrecompSupplier;
use App::Racoco::Coverable::Precomp::PrecompLookup;
use App::Racoco::Coverable::Precomp::Precompiler;
use App::Racoco::Coverable::CoverableIndex;
use App::Racoco::Coverable::CoverableOutliner;
use App::Racoco::Coverable::Precomp::PrecompHashcodeReader;
use App::Racoco::Coverable::CoverableLinesSupplier;
use App::Racoco::CoverableLinesCollector;
use App::Racoco::Report::Data;
use App::Racoco::Misc;

unit class App::Racoco is export;

has IO::Path $.root is required;
has Configuration $.config is required;
has Paths $!paths;
has RunProc $!proc;
has Data $.data;

submethod TWEAK {
$!proc = RunProc.new;
$!paths = make-paths-from(:$!config, :$!root);
}

method calculate-coverage(::?CLASS:D: --> App::Racoco:D) {
my $covered-collector = self!create-covered-collector;
my $coverable-collector = self!create-coverable-collector;
if $!config<exec> {
indir $!root, {
my $previous-data = $!config{BoolKey.of: 'append'} ?? self!read-data !! Nil;
my %covered = $covered-collector.collect();
my %coverable = $coverable-collector.collect();
$!data = Data.plus(Data.new(:%coverable, :%covered), $previous-data);
$!data.write(:$!paths);
}
} else {
$!data = self!read-data;
}
return self;
}

method !create-covered-collector() {
my $result;
indir $!root, {
$result = CoveredLinesCollector.new(
exec => $!config<exec>,
print-test-log => !$!config{BoolKey.of: 'silent'},
append => $!config{BoolKey.of: 'append'},
:$!paths,
:$!proc,
);
};
return $result;
}

method !create-coverable-collector() {
my $result;
indir $!root, {
my $raku = $!config{ExecutableInDirKey.of: 'raku-bin-dir', 'raku'};
my $moar = $!config{ExecutableInDirKey.of: 'raku-bin-dir', 'moar'};
my $precomp-supplier = PrecompSupplierReal.new(
lookup => PrecompLookup.new(
:$!paths, compiler-id => compiler-id(:$raku, :$!proc)
),
precompiler => Precompiler.new(:$!paths, :$raku, :$!proc)
);
my $index = CoverableIndexFile.new(:$!paths);
my $outliner = CoverableOutlinerReal.new(:$!proc, :$moar);
my $hashcode-reader = PrecompHashcodeReaderReal.new;
my $coverable-supplier = CoverableLinesSupplier.new(
supplier => $precomp-supplier, :$index, :$outliner, :$hashcode-reader
);
$result = CoverableLinesCollector.new(
supplier => $coverable-supplier, :$!paths
);
};
return $result;
}

method !read-data() {
Data.read(:$!paths)
}

method do-report(::?CLASS:D: --> App::Racoco:D) {
return without $!data;
$!config{ReporterClassesKey.of: 'reporter'}
.map({ $_.new.do(:$!paths, :$!data, :$!config) });
return self;
}

method how-below-fail-level(::?CLASS:D: --> Int:D) {
return 146 without $!data;
return $!config{IntKey.of('fail-level')} - $!data.percent.Int;
}
Loading

0 comments on commit ac7b983

Please sign in to comment.