diff --git a/src/jobs/job1.ts b/.github/cron/job1.ts similarity index 96% rename from src/jobs/job1.ts rename to .github/cron/job1.ts index e506524..800b0d3 100755 --- a/src/jobs/job1.ts +++ b/.github/cron/job1.ts @@ -1,3 +1,5 @@ +#!/usr/bin/env -S deno run -A + import process from 'node:process' import $ from 'dax/mod.ts' import { colors } from 'dax/src/deps.ts' @@ -38,6 +40,3 @@ console.log(bar) console.log(chalk.bgBlue.red('hello world')) console.log(colors.red(colors.bgBlue('hello world'))) - - - diff --git a/src/jobs/job2.ts b/.github/cron/job2.ts similarity index 100% rename from src/jobs/job2.ts rename to .github/cron/job2.ts diff --git a/.github/scripts/ciutil b/.github/scripts/ciutil index 3baa605..b5a9450 100755 --- a/.github/scripts/ciutil +++ b/.github/scripts/ciutil @@ -19,10 +19,9 @@ download() { } preinstall-binaries() { - cp .github/scripts/pstats ~/.local/bin/ cp .github/scripts/ciutil ~/.local/bin/ - for url in $(jq .preinstallBinaries src/package.json | jq -r .[]); do + for url in $(jq .preinstallBinaries package.json | jq -r .[]); do download "$url" & done @@ -56,6 +55,7 @@ git-commit-to-repository() { set-env-variables() { # Action Cache export ACTIONS_CACHE_DIR=$RUNNER_WORKSPACE/.actions-cache + echo ACTIONS_CACHE_DIR=$ACTIONS_CACHE_DIR >> $GITHUB_ENV echo ACTIONS_CACHE_BIN_DIR=$ACTIONS_CACHE_DIR/bin >> $GITHUB_ENV echo PNPM_STORE_DIR=$ACTIONS_CACHE_DIR/pnpm/pnpm-store >> $GITHUB_ENV @@ -115,96 +115,6 @@ show-cache-structure() { echo } -show-system-information() { - while IFS=":" read -r a b; do - case $a in - "MemTotal") - mem_total="${b/kB/}" - ;; - "MemAvailable") - mem_avail=${b/kB/} - ;; - esac - done < /proc/meminfo - - mem_used=$(((mem_total - mem_avail) / 1024)) - mem_total="$((mem_total / 1024))" - cores="$(nproc --all)" - - echo "Cores: $cores" - echo "Memory used: $mem_used Mb" - echo "Memory total: $mem_total Mb" - echo "Public ip: $(curl -sS icanhazip.com)" -} - - -dump-env() { - TOKEN="dump-env-$RANDOM-$RANDOM" - - echo - echo "::group::Environment variables" - echo "::stop-commands::$TOKEN" - env|sort| egrep --color=always '^[^=]+' || true - echo "::$TOKEN::" - echo "::endgroup::" -} - -public-ip() { - echo "$(curl -sS icanhazip.com)" -} -dump-context() { - command -v gron &> /dev/null || (mkdir -p ~/.local/bin &> /dev/null && cd "$_" && wget -q -nv "https://raw.githubusercontent.com/borestad/static-binaries/main/x86_64/bin/gron" && chmod +x gron) - - TOKEN="dump-context-$RANDOM-$RANDOM-token" - echo "::group::Event ($(gron $GITHUB_EVENT_PATH | wc -l))" - echo "::stop-commands::$TOKEN" - gron -c "$GITHUB_EVENT_PATH" || true - echo "::$TOKEN::" - echo "::endgroup::" - - TOKEN="dump-context-$RANDOM-$RANDOM-token" - echo "::group::Github Context ($(gron $DEBUG_DIR/github.json | wc -l))" - echo "::stop-commands::$TOKEN" - gron -c $DEBUG_DIR/github.json || true - echo "::$TOKEN::" - echo "::endgroup::" - - TOKEN="dump-context-$RANDOM-$RANDOM-token" - echo "::group::Job Context ($(gron $DEBUG_DIR/job.json | wc -l))" - echo "::stop-commands::$TOKEN" - gron -c $DEBUG_DIR/job.json || true - echo "::$TOKEN::" - echo "::endgroup::" - - TOKEN="dump-context-$RANDOM-$RANDOM-token" - echo "::group::Steps Context ($(gron $DEBUG_DIR/steps.json | wc -l))" - echo "::stop-commands::$TOKEN" - gron -c $DEBUG_DIR/steps.json || true - echo "::$TOKEN::" - echo "::endgroup::" - - TOKEN="dump-context-$RANDOM-$RANDOM-token" - echo "::group::Runner Context ($(gron $DEBUG_DIR/runner.json | wc -l))" - echo "::stop-commands::$TOKEN" - gron -c $DEBUG_DIR/runner.json || true - echo "::$TOKEN::" - echo "::endgroup::" - - TOKEN="dump-context-$RANDOM-$RANDOM-token" - echo "::group::Strategy Context ($(gron $DEBUG_DIR/strategy.json | wc -l))" - echo "::stop-commands::$TOKEN" - gron -c $DEBUG_DIR/strategy.json || true - echo "::$TOKEN::" - echo "::endgroup::" - - TOKEN="dump-context-$RANDOM-$RANDOM-token" - echo "::group::Matrix Context ($(gron $DEBUG_DIR/matrix.json | wc -l))" - echo "::stop-commands::$TOKEN" - gron -c $DEBUG_DIR/matrix.json || true - echo "::$TOKEN::" - echo "::endgroup::" -} - # ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ # Formatters / Printers # ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/.github/scripts/pstats b/.github/scripts/pstats deleted file mode 100755 index 4f7d55f..0000000 --- a/.github/scripts/pstats +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# Inspired from this blog article : http://www.thegeekstuff.com/2013/10/time-command-format/ - -if [[ ! -z "${CI}" ]]; then - # Github Actions color works in mysterious ways ... - BAR="_" -else - BAR=" " -fi - -if [ $# -eq 0 ]; then - echo "Usage: $0 command ..." - echo "" - exit 1 -fi - -FILE=$(mktemp) - -time=$(command -v gtime || command -v /usr/bin/time) -grep=$(command -v ggrep || command -v /usr/bin/grep) - -$time -o $FILE -f " Total $BAR %es [%P %MK %I/%O]" ets -s -f "%Mm %S.%Ls $BAR" -- "$@" -code=$? - -echo " $BAR" -cat $FILE -exit $code diff --git a/.github/scripts/setup b/.github/scripts/setup index 39986e9..2fc0869 100755 --- a/.github/scripts/setup +++ b/.github/scripts/setup @@ -6,7 +6,6 @@ GITROOT=`git-root` initstart=$(time-now) - # ============================================================================= # Setup # ============================================================================= @@ -20,10 +19,10 @@ preinstall-binaries # DEBUG # ============================================================================= ✨ "Debug: System information" -show-system-information +system-info ✨ "Debug: Env variables" -dump-env +ga-dump-env show-cache-structure timestamp @@ -31,20 +30,16 @@ timestamp # ============================================================================= # Install node_modules # ============================================================================= -if cat $GITROOT/src/package.json | jq -e .dependencies &>/dev/null; then +if cat $GITROOT/package.json | jq -e .dependencies &>/dev/null; then ✨ "pnpm install" - cd $GITROOT/src + cd $GITROOT # Applying dirty fix for *not* including @types/* in the production ci cp pnpm-lock.yaml $RUNNER_TEMPDIR/ grep -v "'@types/" $RUNNER_TEMPDIR/pnpm-lock.yaml >| pnpm-lock.yaml - pnpm install \ - --frozen-lockfile \ - --production \ - --prefer-offline \ - --no-verify-store-integrity + pnpm install --frozen-lockfile --production --prefer-offline --no-verify-store-integrity mv $RUNNER_TEMPDIR/pnpm-lock.yaml . timestamp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92fbd2c..bccbfb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,7 +74,7 @@ jobs: - name: Cron ❯❯ Job1 # if: github.event.schedule != '*/5 * * * *' run: | - cd src && pstats memo --ttl=300s -- 'deno task job1' + pstats memo --ttl=300s -- 'deno run -A .github/cron/job1.ts' # ───────────────────────────────────────────────────── - name: Post hooks ❯❯ Commit to repository @@ -93,7 +93,7 @@ jobs: JSON_STRATEGY: ${{ toJSON(strategy) }} JSON_MATRIX: ${{ toJSON(MATRIX) }} run: | - .github/scripts/ciutil public-ip + ip-public .github/scripts/ciutil show-cache-structure .github/scripts/ciutil ___ @@ -104,5 +104,5 @@ jobs: printf "$JSON_STRATEGY" >> $DEBUG_DIR/strategy.json printf $JSON_MATRIX >> $DEBUG_DIR/matrix.json - .github/scripts/ciutil dump-context + ga-dump-context diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 4f07d1c..0000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "recommendations": [ - "jeff-hykin.better-shellscript-syntax", - "denoland.vscode-deno", - "ryanluker.vscode-coverage-gutters" - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json index c72340b..6277b5d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "deno.enable": true, - "deno.importMap": "./src/deno.json", + "deno.importMap": "./deno.json", "deno.suggest.autoImports": true, "deno.suggest.completeFunctionCalls": true, "deno.suggest.imports.autoDiscover": true, @@ -26,9 +26,10 @@ "typescriptreact", "yaml" ], - "prettier.enable": false, "files.associations": { "deno.json": "jsonc", "dprint.json": "jsonc" - } + }, + "files.exclude": {}, + "prettier.enable": false } diff --git a/src/deno.json b/deno.json similarity index 86% rename from src/deno.json rename to deno.json index 2fa5fcd..0824de1 100644 --- a/src/deno.json +++ b/deno.json @@ -13,8 +13,6 @@ } }, "tasks": { - "dev": "deno run -A --watch jobs/job1.ts", - "job1": "deno run -A jobs/job1.ts", "update:lockfile": "fd .ts . -tf --threads=1 -X deno cache --import-map=deno.json --unstable --lock=deno.lock --lock-write" } } diff --git a/src/deno.lock b/deno.lock similarity index 100% rename from src/deno.lock rename to deno.lock diff --git a/src/package.json b/package.json similarity index 83% rename from src/package.json rename to package.json index 650099d..aeda2ce 100644 --- a/src/package.json +++ b/package.json @@ -14,12 +14,17 @@ "eslint-plugin-unicorn": "^44.0.2" }, "preinstallBinaries": [ - "https://raw.githubusercontent.com/borestad/static-binaries/main/x86_64/gron", - "https://raw.githubusercontent.com/borestad/static-binaries/main/x86_64/sponge", - "https://raw.githubusercontent.com/borestad/static-binaries/main/x86_64/ets", + "https://raw.githubusercontent.com/borestad/ci-utils/main/bin/ga-dump-context", + "https://raw.githubusercontent.com/borestad/ci-utils/main/bin/ga-dump-env", + "https://raw.githubusercontent.com/borestad/ci-utils/main/bin/ip-public", + "https://raw.githubusercontent.com/borestad/ci-utils/main/bin/memo", + "https://raw.githubusercontent.com/borestad/ci-utils/main/bin/pstats", + "https://raw.githubusercontent.com/borestad/ci-utils/main/bin/system-info", "https://raw.githubusercontent.com/borestad/static-binaries/main/x86_64/bkt", "https://raw.githubusercontent.com/borestad/static-binaries/main/x86_64/dust", - "https://raw.githubusercontent.com/borestad/ci-utils/main/bin/memo" + "https://raw.githubusercontent.com/borestad/static-binaries/main/x86_64/ets", + "https://raw.githubusercontent.com/borestad/static-binaries/main/x86_64/gron", + "https://raw.githubusercontent.com/borestad/static-binaries/main/x86_64/sponge" ], "eslintConfig": { "extends": "@antfu", @@ -30,7 +35,7 @@ "parserOptions": { "ecmaVersion": 2023, "sourceType": "module", - "project": "src/tsconfig.json" + "project": "tsconfig.json" }, "plugins": [ "unicorn" diff --git a/src/pnpm-lock.yaml b/pnpm-lock.yaml similarity index 100% rename from src/pnpm-lock.yaml rename to pnpm-lock.yaml diff --git a/src/tsconfig.json b/tsconfig.json similarity index 90% rename from src/tsconfig.json rename to tsconfig.json index 95b66f6..b3822bb 100644 --- a/src/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "extends": "@tsconfig/deno/tsconfig.json", "include": [ "./**/*.ts", + "./.github/cron/*.ts", "./**/*.mjs" ], "exclude": [ @@ -10,6 +11,7 @@ ], "compilerOptions": { "baseUrl": ".", + "rootDir": ".", "target": "ESNext", "outDir": "./dist", "module": "esnext",