Skip to content

Commit

Permalink
cov (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
spalberg authored Dec 4, 2024
1 parent 46d3a08 commit d22f5ec
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
- run: deno test --allow-read --parallel --junit-path=./junit.xml
- uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
- run: deno test --allow-read --parallel --coverage=cov/ --junit-path=./junit.xml
- run: deno coverage --lcov cov/ > cov.lcov
- uses: codecov/codecov-action@v5
with:
files: junit.xml
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/test-results-action@v1
if: ${{ !cancelled() }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
29 changes: 29 additions & 0 deletions cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { colors } from "@cliffy/ansi/colors";
import { Command } from "@cliffy/command";
import { Input, Select } from "@cliffy/prompt";
import { greaterThan, parse } from "@std/semver";
import { readLinesFromFile } from "utils";
import { days } from "./days/mod.ts";
import denoJson from "./deno.json" with { type: "json" };
Expand All @@ -18,6 +19,33 @@ const list = new Command()
}
});

const update = new Command()
.description("Update to the latest version")
.action(async () => {
const { latest } = await fetch(`https://jsr.io/${denoJson.name}/meta.json`)
.then(
(res) => res.json(),
);
const isUpdateAvailable = greaterThan(
parse(latest),
parse(denoJson.version),
);
if (isUpdateAvailable) {
console.log(
colors.bold.yellow(
`Update available: ${denoJson.version} -> ${latest}`,
),
);
console.log("Updating...");
await new Deno.Command(Deno.execPath(), {
args: ["run", "-r", `jsr:@aoc/2024`, "--help"],
}).output();
console.log(colors.bold.green("Updated successfully"));
} else {
console.log(colors.bold.green("Already up to date"));
}
});

const main = new Command()
.name("Advent of Code - 2024")
.version(denoJson.version)
Expand Down Expand Up @@ -83,5 +111,6 @@ function isWebUrl(path: string): boolean {
if (import.meta.main) {
await main
.command("list", list)
.command("update", update)
.parse(Deno.args);
}
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"exports": "./cli.ts",
"tasks": {
"cli": "deno run --allow-read ./cli.ts",
"cli": "deno run -RN ./cli.ts",
"update:version": "deno run -A ./scripts/update_version.ts"
},
"imports": {
Expand Down
12 changes: 12 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d22f5ec

Please sign in to comment.