Skip to content

Commit

Permalink
Merge pull request #3 from borestad/feature/testing
Browse files Browse the repository at this point in the history
  • Loading branch information
borestad authored Jul 30, 2023
2 parents 2b82ed2 + df5c0f1 commit 4baac2e
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 153 deletions.
5 changes: 2 additions & 3 deletions src/jobs/job1.ts → .github/cron/job1.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -38,6 +40,3 @@ console.log(bar)

console.log(chalk.bgBlue.red('hello world'))
console.log(colors.red(colors.bgBlue('hello world')))



File renamed without changes.
94 changes: 2 additions & 92 deletions .github/scripts/ciutil
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Expand Down
28 changes: 0 additions & 28 deletions .github/scripts/pstats

This file was deleted.

15 changes: 5 additions & 10 deletions .github/scripts/setup
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ GITROOT=`git-root`

initstart=$(time-now)


# =============================================================================
# Setup
# =============================================================================
Expand All @@ -20,31 +19,27 @@ preinstall-binaries
# DEBUG
# =============================================================================
"Debug: System information"
show-system-information
system-info

"Debug: Env variables"
dump-env
ga-dump-env

show-cache-structure
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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ___
Expand All @@ -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
7 changes: 0 additions & 7 deletions .vscode/extensions.json

This file was deleted.

7 changes: 4 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -26,9 +26,10 @@
"typescriptreact",
"yaml"
],
"prettier.enable": false,
"files.associations": {
"deno.json": "jsonc",
"dprint.json": "jsonc"
}
},
"files.exclude": {},
"prettier.enable": false
}
2 changes: 0 additions & 2 deletions src/deno.json → deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
File renamed without changes.
15 changes: 10 additions & 5 deletions src/package.json → package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -30,7 +35,7 @@
"parserOptions": {
"ecmaVersion": 2023,
"sourceType": "module",
"project": "src/tsconfig.json"
"project": "tsconfig.json"
},
"plugins": [
"unicorn"
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/tsconfig.json → tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "@tsconfig/deno/tsconfig.json",
"include": [
"./**/*.ts",
"./.github/cron/*.ts",
"./**/*.mjs"
],
"exclude": [
Expand All @@ -10,6 +11,7 @@
],
"compilerOptions": {
"baseUrl": ".",
"rootDir": ".",
"target": "ESNext",
"outDir": "./dist",
"module": "esnext",
Expand Down

0 comments on commit 4baac2e

Please sign in to comment.