mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-11-24 17:06:21 +01:00
Compare commits
3 Commits
54337a662e
...
0928dfdd13
| Author | SHA1 | Date | |
|---|---|---|---|
| 0928dfdd13 | |||
| 7515bd0dc2 | |||
| 50263f075a |
30
.github/workflows/md-naming.yml
vendored
Normal file
30
.github/workflows/md-naming.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: md-naming
|
||||
|
||||
# Deliberately a SEPARATE workflow from pre-commit.yml: one workflow per gate,
|
||||
# so a naming failure is legible on its own rather than buried in a suite.
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
md-naming:
|
||||
name: markdown naming convention
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
# The gate and its exemption list live in the shared utils repo so every
|
||||
# repo enforces the same rule. Checking it out beats vendoring a copy,
|
||||
# which is how a gate and a survey start disagreeing.
|
||||
- name: Check out the shared gate
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kuhyx/utils
|
||||
path: .utils
|
||||
|
||||
- name: Enforce the naming convention
|
||||
run: bash .utils/scripts/check_md_naming.sh --all
|
||||
63
.github/workflows/pre-commit.yml
vendored
Normal file
63
.github/workflows/pre-commit.yml
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
name: pre-commit
|
||||
|
||||
# The local hooks can be skipped -- a fresh clone that never ran ./install.sh
|
||||
# has no hooks at all -- so the gate needs a second home that nobody can
|
||||
# forget to install.
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
pre-commit:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
# scripts/check_md_naming.sh is a thin shim that execs the shared gate
|
||||
# out of the utils repo. A runner has no ~/utils, so without this the
|
||||
# hook fails with "shared gate not found".
|
||||
UTILS_ROOT: ${{ github.workspace }}/.utils
|
||||
steps:
|
||||
# fetch-depth 1: the history here is ~494 MB and no gate reads it.
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Check out the shared gates
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kuhyx/utils
|
||||
path: .utils
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
# Pinned, not apt-installed. `language: system` hooks run whatever is on
|
||||
# PATH, so an unpinned shellcheck makes CI disagree with every developer
|
||||
# machine: Ubuntu's package flagged SC2236 in a file that 0.11.0 locally
|
||||
# does not, and the build went red for a difference in tool version
|
||||
# rather than in the code.
|
||||
- name: Install shellcheck (pinned)
|
||||
env:
|
||||
SHELLCHECK_VERSION: v0.11.0
|
||||
SHELLCHECK_SHA256: 8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198
|
||||
run: |
|
||||
set -euo pipefail
|
||||
url="https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz"
|
||||
curl -fsSL "$url" -o /tmp/sc.tar.xz
|
||||
echo "${SHELLCHECK_SHA256} /tmp/sc.tar.xz" | sha256sum -c -
|
||||
tar -xJf /tmp/sc.tar.xz -C /tmp
|
||||
sudo install -m 0755 "/tmp/shellcheck-${SHELLCHECK_VERSION}/shellcheck" /usr/local/bin/shellcheck
|
||||
shellcheck --version
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pre-commit
|
||||
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
|
||||
- name: Install pre-commit
|
||||
run: python -m pip install --quiet pre-commit
|
||||
|
||||
- name: Run the hooks
|
||||
run: pre-commit run --all-files --show-diff-on-failure
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@ -475,3 +475,7 @@ target/
|
||||
!**/.vscode/*
|
||||
!**/.idea/
|
||||
!**/.idea/**
|
||||
|
||||
# Generated by nginx/ssl/generate-cert.sh -- never commit a private key.
|
||||
Programming/ERSMS-project/nginx/ssl/nginx.key
|
||||
Programming/ERSMS-project/nginx/ssl/nginx.crt
|
||||
|
||||
71
.pre-commit-config.yaml
Normal file
71
.pre-commit-config.yaml
Normal file
@ -0,0 +1,71 @@
|
||||
# Install: ./install.sh (or: pre-commit install && pre-commit install --hook-type pre-push)
|
||||
# Fast lint: pre-commit run --all-files
|
||||
#
|
||||
# Ordering rule for this repo: a hook lands only once the thing it gates is
|
||||
# already clean, so `pre-commit run --all-files` is green at every commit.
|
||||
# Hooks still to come, each blocked on its own cleanup:
|
||||
# - file-length blocked on the .tex/code splits and TODO-file-length-250.md
|
||||
# - ruff / mypy blocked on the root pyproject.toml (Milestone 4)
|
||||
# - dependency-freshness blocked on the upgrade itself; the gate and the
|
||||
# upgrade must land in the SAME commit or the repo is
|
||||
# instantly and permanently red
|
||||
# - trailing-whitespace / end-of-file-fixer these REWRITE files, so they get
|
||||
# their own reviewed cleanup commit first
|
||||
default_language_version:
|
||||
python: python3
|
||||
default_stages: [pre-commit]
|
||||
fail_fast: false
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.6.0
|
||||
hooks:
|
||||
# Structural checks only -- none of these rewrite a file.
|
||||
- id: check-merge-conflict
|
||||
- id: check-case-conflict
|
||||
- id: check-symlinks
|
||||
- id: destroyed-symlinks
|
||||
- id: detect-private-key
|
||||
# tsconfig*.json and .vscode/*.json are JSONC -- both TypeScript and
|
||||
# VS Code document comments and trailing commas as valid there, and
|
||||
# check-json uses a strict RFC parser. This is the wrong parser for
|
||||
# those files, not a defect being suppressed; every other .json is
|
||||
# still checked. (The one real failure this hook found, a committed
|
||||
# merge conflict in EARIN/.vscode/extensions.json, is fixed.)
|
||||
- id: check-json
|
||||
exclude: |
|
||||
(?x)^(
|
||||
.*/tsconfig[^/]*\.json|
|
||||
.*/\.vscode/[^/]*\.json
|
||||
)$
|
||||
- id: check-toml
|
||||
- id: check-yaml
|
||||
args: [--unsafe]
|
||||
# 2 MB. The four 39 MB movies.csv copies are already tracked and stay
|
||||
# (approved decision 6); this stops the NEXT one.
|
||||
- id: check-added-large-files
|
||||
args: [--maxkb=2000]
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
# Coursework deliverables are allowed under the two course trees;
|
||||
# compiled output is allowed nowhere. See .binary-allowlist.
|
||||
- id: no-binaries
|
||||
name: block binary files outside the allowlist
|
||||
entry: scripts/check_no_binaries.sh
|
||||
language: script
|
||||
pass_filenames: true
|
||||
|
||||
# Thin shim into ~/utils, which owns the four markdown namespaces.
|
||||
- id: md-naming
|
||||
name: markdown naming convention
|
||||
entry: scripts/check_md_naming.sh
|
||||
language: system
|
||||
files: \.(md|markdown)$
|
||||
|
||||
- id: shellcheck
|
||||
name: shellcheck
|
||||
entry: bash -c 'printf "%s\0" "$@" | xargs -0 -n 40 shellcheck' --
|
||||
language: system
|
||||
types: [shell]
|
||||
exclude_types: [zsh]
|
||||
54
DOCS-runnability.md
Normal file
54
DOCS-runnability.md
Normal file
@ -0,0 +1,54 @@
|
||||
# Runnability
|
||||
|
||||
Generated by `./run.sh status`. Do not edit by hand.
|
||||
|
||||
Status is recorded PER ENVIRONMENT. A directory that is `runnable` locally and
|
||||
`blocked` in CI is the normal case, not drift: the runner has no MATLAB, no
|
||||
Unity and no .NET SDK. CI compares only its own column.
|
||||
|
||||
| Course | local | Detail |
|
||||
|---|---|---|
|
||||
| `NotProgramming/DPZ` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/ECOGR` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/EDABA` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/EDABA-LAB` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/EDISE` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/EDISP` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/ELAC` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/EMISY` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/ENUME` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/EPHY2` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/EPOGAI` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/ERPM` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/ESDP1` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/ESOEN` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/MOM` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/SDM` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/SDM2` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/SPD` | unprobed | no run.sh yet |
|
||||
| `NotProgramming/STUP` | unprobed | no run.sh yet |
|
||||
| `Programming/AIS` | unprobed | no run.sh yet |
|
||||
| `Programming/BD2` | unprobed | no run.sh yet |
|
||||
| `Programming/BSS` | unprobed | no run.sh yet |
|
||||
| `Programming/EADS` | unprobed | no run.sh yet |
|
||||
| `Programming/EARIN` | unprobed | no run.sh yet |
|
||||
| `Programming/ECOAR` | unprobed | no run.sh yet |
|
||||
| `Programming/ECOTE` | unprobed | no run.sh yet |
|
||||
| `Programming/ECRYPT` | unprobed | no run.sh yet |
|
||||
| `Programming/ECRYPT_PROJECT` | unprobed | no run.sh yet |
|
||||
| `Programming/EGUI` | unprobed | no run.sh yet |
|
||||
| `Programming/EOOP` | unprobed | no run.sh yet |
|
||||
| `Programming/EOPSY` | unprobed | no run.sh yet |
|
||||
| `Programming/EPFU` | unprobed | no run.sh yet |
|
||||
| `Programming/E-PSYOPS` | unprobed | no run.sh yet |
|
||||
| `Programming/ERSMS-project` | unprobed | no run.sh yet |
|
||||
| `Programming/NLP` | unprobed | no run.sh yet |
|
||||
| `Programming/PBAD` | unprobed | no run.sh yet |
|
||||
| `Programming/PORR` | unprobed | no run.sh yet |
|
||||
| `Programming/PSD` | unprobed | pre-existing run.sh, no --probe support |
|
||||
| `Programming/psd_project` | unprobed | no run.sh yet |
|
||||
| `Programming/TRAK` | unprobed | no run.sh yet |
|
||||
| `Programming/twm_4` | unprobed | no run.sh yet |
|
||||
| `Programming/USD` | unprobed | no run.sh yet |
|
||||
| `Programming/WDWR` | unprobed | no run.sh yet |
|
||||
| `Programming/ZPOB` | unprobed | no run.sh yet |
|
||||
@ -35,7 +35,7 @@ $INSTALL_CMD postgresql
|
||||
|
||||
# Initialize the database cluster (Arch only)
|
||||
if [[ $INSTALL_CMD == *"pacman"* ]]; then
|
||||
sudo -iu postgres initdb --locale $LANG -E UTF8 -D "$CONFIG_DIR"
|
||||
sudo -iu postgres initdb --locale "$LANG" -E UTF8 -D "$CONFIG_DIR"
|
||||
fi
|
||||
|
||||
# Start and enable PostgreSQL service
|
||||
@ -62,5 +62,5 @@ $SERVICE_CMD restart postgresql
|
||||
export DATABASE_URL="postgresql://$DB_USER:$DB_PASSWORD@localhost:$DB_PORT/$DB_NAME?schema=$DB_SCHEMA"
|
||||
|
||||
# Print the DATABASE_URL to verify
|
||||
echo "DATABASE_URL="$DATABASE_URL""
|
||||
echo "DATABASE_URL=$DATABASE_URL"
|
||||
echo "PostgreSQL setup is complete. The database is accessible at the specified URL."
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Scaffold an Angular component per data model.
|
||||
set -euo pipefail
|
||||
# Define the project name
|
||||
PROJECT_NAME="frontend"
|
||||
|
||||
@ -17,7 +20,7 @@ generate_module_and_service() {
|
||||
|
||||
# nx g @nrwl/nest:controller ${MODULE_NAME} --directory=apps/${PROJECT_NAME}/src/app/${MODULE_NAME}
|
||||
|
||||
nx g @nx/angular:component ${MODULE_NAME} --directory=apps/${PROJECT_NAME}/src/app/${MODULE_NAME}
|
||||
nx g @nx/angular:component "${MODULE_NAME}" --directory="apps/${PROJECT_NAME}/src/app/${MODULE_NAME}"
|
||||
}
|
||||
|
||||
# List of all models for which we need to generate modules and services
|
||||
@ -25,7 +28,7 @@ MODELS=("restauracja" "recenzja" "uzytkownik" "historia-zamowien" "danie" "zamow
|
||||
|
||||
# Loop through the models and generate modules and services
|
||||
for MODEL in "${MODELS[@]}"; do
|
||||
generate_module_and_service ${MODEL}
|
||||
generate_module_and_service "${MODEL}"
|
||||
done
|
||||
|
||||
echo "All modules and services have been generated successfully."
|
||||
|
||||
@ -1,5 +1,14 @@
|
||||
#!/bin/sh
|
||||
cd apps/backend
|
||||
npx prisma generate
|
||||
cd ../../
|
||||
#!/bin/bash
|
||||
#
|
||||
# Generate the Prisma client, then serve frontend and backend together.
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly SCRIPT_DIR
|
||||
|
||||
# A subshell keeps the cd local, so a failure cannot leave the caller in
|
||||
# apps/backend and run the next command in the wrong directory.
|
||||
(cd "${SCRIPT_DIR}/apps/backend" && npx prisma generate)
|
||||
|
||||
cd "$SCRIPT_DIR"
|
||||
nx run-many --target=serve --projects=frontend,backend --parallel
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
<<<<<<< HEAD
|
||||
guid: 08cb4bdcfd1a3d9198e1d7ccfee220d2
|
||||
=======
|
||||
guid: 5939f2b8303b5cd46afe044fb9d1709e
|
||||
>>>>>>> 98112df (added TickSystem and an example tick receiver)
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
<<<<<<< HEAD
|
||||
guid: c970975bb706c3e158e7748ebf7f5284
|
||||
=======
|
||||
guid: 0249b4cbd93f42540a182f30adbb10bc
|
||||
>>>>>>> 98112df (added TickSystem and an example tick receiver)
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
||||
3
Programming/EARIN/.gitignore
vendored
3
Programming/EARIN/.gitignore
vendored
@ -1,10 +1,8 @@
|
||||
<<<<<<< HEAD
|
||||
*.swp
|
||||
.DS_Store
|
||||
bin/configlet
|
||||
bin/configlet.exe
|
||||
temp.pl
|
||||
=======
|
||||
database
|
||||
test_results
|
||||
anime_with_synopsis.csv
|
||||
@ -314,4 +312,3 @@ TSWLatexianTemp*
|
||||
# option is specified. Footnotes are the stored in a file with suffix Notes.bib.
|
||||
# Uncomment the next line to have this generated file ignored.
|
||||
#*Notes.bib
|
||||
>>>>>>> project/main
|
||||
|
||||
10
Programming/EARIN/.vscode/extensions.json
vendored
10
Programming/EARIN/.vscode/extensions.json
vendored
@ -1,20 +1,12 @@
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
"recommendations": [
|
||||
<<<<<<< HEAD
|
||||
"ms-python.python",
|
||||
"ms-python.pylint",
|
||||
"mikoz.black-py",
|
||||
"james-yu.latex-workshop",
|
||||
"kisstkondoros.vscode-gutter-preview",
|
||||
"streetsidesoftware.code-spell-checker",
|
||||
"wesbos.theme-cobalt2"
|
||||
=======
|
||||
"wesbos.theme-cobalt2",
|
||||
"rebornix.prolog"
|
||||
>>>>>>> lab7/main
|
||||
]
|
||||
}
|
||||
=======
|
||||
"recommendations": ["james-yu.latex-workshop"]
|
||||
}
|
||||
>>>>>>> project/main
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
# the name of the script without a path
|
||||
|
||||
name=`basename $0`
|
||||
name="$(basename "$0")"
|
||||
|
||||
help()
|
||||
{
|
||||
@ -21,7 +21,7 @@ help()
|
||||
|
||||
uppercase()
|
||||
{
|
||||
if test "$1" = $name
|
||||
if test "$1" = "$name"
|
||||
then
|
||||
error_msg "you cannot modify name of this script!"
|
||||
exit 3
|
||||
@ -42,7 +42,7 @@ uppercase()
|
||||
fi
|
||||
fi
|
||||
|
||||
mv "$1" $(echo "$1" | sed -r -e 's/.*/\U&/');
|
||||
mv "$1" "$(echo "$1" | sed -r -e 's/.*/\U&/')";
|
||||
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ uppercase()
|
||||
|
||||
lowercase()
|
||||
{
|
||||
if test "$1" = $name
|
||||
if test "$1" = "$name"
|
||||
then
|
||||
error_msg "you cannot modify name of this script!"
|
||||
exit 3
|
||||
@ -68,12 +68,12 @@ lowercase()
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
mv "$1" $(echo "$1" | sed -r -e 's/.*/\L&/');
|
||||
mv "$1" "$(echo "$1" | sed -r -e 's/.*/\L&/')";
|
||||
}
|
||||
|
||||
sneed()
|
||||
{
|
||||
if test "$2" = $name
|
||||
if test "$2" = "$name"
|
||||
then
|
||||
error_msg "you cannot modify name of this script!"
|
||||
exit 3
|
||||
@ -97,7 +97,7 @@ sneed()
|
||||
fi
|
||||
fi
|
||||
|
||||
mv "$2" $(echo "$2" | sed $1)
|
||||
mv "$2" "$(echo "$2" | sed "$1")"
|
||||
}
|
||||
|
||||
recursionSneed()
|
||||
@ -124,8 +124,8 @@ recursionSneed()
|
||||
fi
|
||||
filename="$2"
|
||||
sneed "$1" "$filename"
|
||||
filename="$(echo "$filename" | sed $1)"
|
||||
echo $filename
|
||||
filename="$(echo "$filename" | sed "$1")"
|
||||
echo "$filename"
|
||||
for item in "$filename"/*
|
||||
do
|
||||
if test -d "$item"
|
||||
|
||||
@ -6,33 +6,19 @@ touch SED
|
||||
mkdir foldera
|
||||
mkdir FOLDERB
|
||||
mkdir FOLDERSED
|
||||
mkdir upperfoldermain
|
||||
cd upperfoldermain
|
||||
touch upperfilesub
|
||||
mkdir upperfoldersub
|
||||
cd upperfoldersub
|
||||
touch upperfilesubsub
|
||||
cd ..
|
||||
cd ..
|
||||
# Build the fixture tree with paths rather than cd/cd .., so a failed cd
|
||||
# cannot silently create the next level in the wrong directory.
|
||||
mkdir -p upperfoldermain/upperfoldersub
|
||||
touch upperfoldermain/upperfilesub
|
||||
touch upperfoldermain/upperfoldersub/upperfilesubsub
|
||||
|
||||
mkdir -p LOWERCASEFOLDERMAIN/LOWERFOLDERSUB
|
||||
touch LOWERCASEFOLDERMAIN/LOWERFILESUB
|
||||
touch LOWERCASEFOLDERMAIN/LOWERFOLDERSUB/LOWERFILESUBSUB
|
||||
|
||||
mkdir LOWERCASEFOLDERMAIN
|
||||
cd LOWERCASEFOLDERMAIN
|
||||
touch LOWERFILESUB
|
||||
mkdir LOWERFOLDERSUB
|
||||
cd LOWERFOLDERSUB
|
||||
touch LOWERFILESUBSUB
|
||||
cd ..
|
||||
cd ..
|
||||
|
||||
mkdir SEDLOWERCASEFOLDERMAIN
|
||||
cd SEDLOWERCASEFOLDERMAIN
|
||||
touch SEDLOWERFILESUB
|
||||
mkdir SEDLOWERFOLDERSUB
|
||||
cd SEDLOWERFOLDERSUB
|
||||
touch SEDLOWERFILESUBSUB
|
||||
cd ..
|
||||
cd ..
|
||||
mkdir -p SEDLOWERCASEFOLDERMAIN/SEDLOWERFOLDERSUB
|
||||
touch SEDLOWERCASEFOLDERMAIN/SEDLOWERFILESUB
|
||||
touch SEDLOWERCASEFOLDERMAIN/SEDLOWERFOLDERSUB/SEDLOWERFILESUBSUB
|
||||
|
||||
touch recursefile
|
||||
touch RECURSELOWERFILE
|
||||
|
||||
41
Programming/ERSMS-project/nginx/ssl/generate-cert.sh
Executable file
41
Programming/ERSMS-project/nginx/ssl/generate-cert.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ============================================================================
|
||||
# Generate the self-signed localhost certificate nginx uses in docker-compose.
|
||||
#
|
||||
# The pair used to be committed. It was a throwaway CN=localhost cert that had
|
||||
# already expired (notAfter 2025-06-16), so nothing depended on those exact
|
||||
# bytes -- but a private key does not belong in a public repository, and this
|
||||
# one is one command to recreate.
|
||||
#
|
||||
# NOTE: removing it from HEAD does not unpublish it. The key is still in git
|
||||
# history, which is deliberately not rewritten. That is acceptable ONLY because
|
||||
# this is an expired self-signed localhost cert with no trust path. A key that
|
||||
# ever protected anything real would have to be rotated, not just deleted.
|
||||
#
|
||||
# Usage: bash generate-cert.sh
|
||||
# ============================================================================
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly SCRIPT_DIR
|
||||
readonly DAYS=365
|
||||
|
||||
main() {
|
||||
if ! command -v openssl > /dev/null 2>&1; then
|
||||
echo "error: openssl is required" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openssl req -x509 -nodes -newkey rsa:2048 \
|
||||
-keyout "${SCRIPT_DIR}/nginx.key" \
|
||||
-out "${SCRIPT_DIR}/nginx.crt" \
|
||||
-days "$DAYS" \
|
||||
-subj "/CN=localhost" 2> /dev/null
|
||||
|
||||
chmod 600 "${SCRIPT_DIR}/nginx.key"
|
||||
echo "==> wrote nginx.crt and nginx.key (self-signed, ${DAYS} days)"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@ -1,19 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDCTCCAfGgAwIBAgIUaPIEdr82RMes6XSaYOB55pQbYDswDQYJKoZIhvcNAQEL
|
||||
BQAwFDESMBAGA1UEAwwJbG9jYWxob3N0MB4XDTI0MDYxNjIxNTYxNloXDTI1MDYx
|
||||
NjIxNTYxNlowFDESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEF
|
||||
AAOCAQ8AMIIBCgKCAQEAlgWNGOpLB7FonzAvxoMmcDKu7SJDAnBd8HnrswRb4noI
|
||||
HCy2b3JOYi5RU66AGfDB9N4YFkhSNYkjSGLQdmoPqFoR5IyFAtvdGQUsAhRl4YP9
|
||||
/ust4NlPAVfxYPGhHyrpPozJK/RYIFcwPDKgMEEI636jHWw6mJaOsVgiMpQgs9oM
|
||||
V4b5b9LfB6wD72pi6Ag6xMi5PUvj91UfvkR59Gy844zriyV094saxwBRCL6naSMA
|
||||
vToVFIcaGCIXHfO2DiTVq4dDkCkHYRiva64UcV08x0I2GyxNLCUsjgDrQy/pRfdn
|
||||
QE1QO55LoDk4SI3U0PSGCyBMg0Kr7eC+6MwhjI/2ewIDAQABo1MwUTAdBgNVHQ4E
|
||||
FgQUZQxFwZhHP7+N2huK4T8S4+dCMoIwHwYDVR0jBBgwFoAUZQxFwZhHP7+N2huK
|
||||
4T8S4+dCMoIwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEALTJ4
|
||||
1bql/QkcM7t3DSCm7H7NK0fW9+3G/FYtCQUxvs3+rFvxymHbwHERbR1AReJy2Brx
|
||||
ayNMQNUA48sUa2VsRxEv1f/Qb5WVue3rIonugZ792bsI+6yMVxYVt97ETAnalSH4
|
||||
L3kWqGWJnkyfMm3RB7sGEFVnO2/s+vEhbzCRpCt2qda1pXPIBagPSCFm3InU9+Tq
|
||||
2bDsASuUEEz7RWTPa/R1qkCU5Sl3+CZUpTIpRDxB2MCaGk+FXQ9u2CpZBiZDOL/p
|
||||
e0Af5yhYlNBHp+Ut+N1kQSKKyOqlrqkN92nx7NLqOYBkjfkns9lTciyKiKefq08G
|
||||
qesECi3RgXXuG6xv5Q==
|
||||
-----END CERTIFICATE-----
|
||||
@ -1,28 +0,0 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCWBY0Y6ksHsWif
|
||||
MC/GgyZwMq7tIkMCcF3weeuzBFvieggcLLZvck5iLlFTroAZ8MH03hgWSFI1iSNI
|
||||
YtB2ag+oWhHkjIUC290ZBSwCFGXhg/3+6y3g2U8BV/Fg8aEfKuk+jMkr9FggVzA8
|
||||
MqAwQQjrfqMdbDqYlo6xWCIylCCz2gxXhvlv0t8HrAPvamLoCDrEyLk9S+P3VR++
|
||||
RHn0bLzjjOuLJXT3ixrHAFEIvqdpIwC9OhUUhxoYIhcd87YOJNWrh0OQKQdhGK9r
|
||||
rhRxXTzHQjYbLE0sJSyOAOtDL+lF92dATVA7nkugOThIjdTQ9IYLIEyDQqvt4L7o
|
||||
zCGMj/Z7AgMBAAECggEAEYz2s8p9GppLpgvqGuwu7ANR6ZYPhtKEeuSYiWniIf2q
|
||||
wzkL4r/ZoazPgN2ySNacqjvtT3YIgBDaGtbMkn3X9RcMbtNtoCb+l7W+L0QZoydg
|
||||
6Ji01lA16O9T4saB1facMOAhjM3aHXZ1wyUdDmgdVgeLp56IwF8ktGSeI5KmvMOA
|
||||
tHH20ZaG0Iy9kHjqgnRTKsF1giUl4XtNR0tbzVBdzvXZz8BPzAtNkC0QwcA3r6Mr
|
||||
PRzpelCQ9cFdbbpssy73aZ4cu30nVYdIuHFCmB25QdOt6Uzo4yoxmUK3PSKjf0py
|
||||
Ow5fHN5UqB1vZ0C/zNAapeg9elZvsYMU+LSUkGknaQKBgQDNfBb/FasjhPLstiHR
|
||||
U8LXTLinsU5qtKDVQIEpxQOub3lwRFs8bK0T2PfdbNJqUv55B301ORpbyqXLWS9N
|
||||
BNEUWkQ0Tpw9CsnItENvQnObUh6iIPU0uKLSp8Vnj4v3zOLfAMBZMitqbituqooE
|
||||
rrXmv9Oy3Sa/G1gX6HC7Hrdv/wKBgQC65vfMjmYXXRL47puTkfkBVWIZPV5WNq2F
|
||||
VnEarBUcO4ZqwweKKzO38mLXFWVcxz9QGzznoR/ndi1KGJSmBPbYPJwIKEcUCgZv
|
||||
25QUsVstV7mB2O53YEYfr4eGx0+lacofSYOcNV//Mrf1VcEQn8stme+hRp3xsvRa
|
||||
FAni8K05hQKBgQCWc8IeuU3aLvDzMpPmQa8Klwko92CULncITTeFTtRYNxSyh8pJ
|
||||
nsTHIHizrocOBICAO2SIwKu1A9aK4l0IxnsTrNf9eIVbCHggNSSe5QfidKkrSnhf
|
||||
RsUo+mBGaEsyf9ipMVKkvGAfiFTSrZlqvkU/k7q8XsKM8Md6kd1glKf5HwKBgGp0
|
||||
Q4/vS5bjHHtM7LAQ5JMt3sIhgin42rynj6Rxf1SlUtpcW18HXF3ZYRLAzQsbMaSe
|
||||
3wHPdCyR0xnxBjnJeg+P9g9vYYy4aRItLxraKeSZor+in7C+1TIW+Ep8G5FLwCQx
|
||||
6xR+Ej940+6Y+W5OlZtTonlpj2yrUSI9Z6QrEX9BAoGADH9nrJ+Gl6GaTEtlTHUQ
|
||||
XbQLmlfffQPIvc+v6z6TAvuULqQrK/Tya8s5dqDmM+RfoU12vij4yCblChDo8Pef
|
||||
IgInN2S7hmuMHVB5QdVHoiHzVnryIsr29fR9jDp3QP7AnnFJbZ5sOQxId+0KpYtG
|
||||
ZTcpATmbdu3hUJSNSpK1+ig=
|
||||
-----END PRIVATE KEY-----
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
# Function to run a script in the background and save its PID
|
||||
run_script() {
|
||||
python $1 &
|
||||
python "$1" &
|
||||
echo $!
|
||||
}
|
||||
|
||||
@ -25,9 +25,7 @@ install_flink() {
|
||||
echo "yay is not installed. Installing yay..."
|
||||
sudo pacman -S --noconfirm git
|
||||
git clone https://aur.archlinux.org/yay.git
|
||||
cd yay
|
||||
makepkg -si --noconfirm
|
||||
cd ..
|
||||
( cd yay && makepkg -si --noconfirm )
|
||||
rm -rf yay
|
||||
fi
|
||||
yay -S --noconfirm apache-flink
|
||||
@ -80,10 +78,10 @@ echo "Started Flask alarm reader with PID $flask_pid"
|
||||
# Function to handle script termination
|
||||
terminate_scripts() {
|
||||
echo "Shutting down..."
|
||||
kill $producer_pid
|
||||
kill $consumer_pid
|
||||
kill $flink_pid
|
||||
kill $flask_pid
|
||||
kill "$producer_pid"
|
||||
kill "$consumer_pid"
|
||||
kill "$flink_pid"
|
||||
kill "$flask_pid"
|
||||
echo "All processes terminated."
|
||||
# Optionally stop Kafka and Flink services
|
||||
sudo systemctl stop kafka
|
||||
|
||||
@ -31,17 +31,17 @@ cleanup() {
|
||||
echo -e "${YELLOW}Shutting down the temperature monitoring system...${NC}"
|
||||
|
||||
# Kill all background processes
|
||||
if [[ ! -z $GENERATOR_PID ]]; then
|
||||
if [[ -n "${GENERATOR_PID}" ]]; then
|
||||
echo "Stopping temperature generator..."
|
||||
kill $GENERATOR_PID 2>/dev/null || true
|
||||
fi
|
||||
|
||||
if [[ ! -z $DETECTOR_PID ]]; then
|
||||
if [[ -n "${DETECTOR_PID}" ]]; then
|
||||
echo "Stopping anomaly detector..."
|
||||
kill $DETECTOR_PID 2>/dev/null || true
|
||||
fi
|
||||
|
||||
if [[ ! -z $VISUALIZER_PID ]]; then
|
||||
if [[ -n "${VISUALIZER_PID}" ]]; then
|
||||
echo "Stopping alarm visualizer..."
|
||||
kill $VISUALIZER_PID 2>/dev/null || true
|
||||
fi
|
||||
|
||||
@ -3,7 +3,9 @@
|
||||
# Configuration
|
||||
VENV_NAME="psd_env"
|
||||
VENV_PATH="$(pwd)/${VENV_NAME}"
|
||||
PYTHON_VERSION="3.8" # Specify the Python version you want to use
|
||||
# Recorded for reference: the interpreter this project was developed against.
|
||||
# Not used by the script, which takes whatever python3 is on PATH.
|
||||
export PYTHON_VERSION="3.8"
|
||||
REQUIREMENTS=(
|
||||
"confluent-kafka"
|
||||
"apache-flink"
|
||||
@ -21,8 +23,7 @@ fi
|
||||
# Create virtual environment if it doesn't exist
|
||||
if [ ! -d "$VENV_PATH" ]; then
|
||||
echo "Creating virtual environment at $VENV_PATH..."
|
||||
python3 -m venv "$VENV_PATH"
|
||||
if [ $? -ne 0 ]; then
|
||||
if ! python3 -m venv "$VENV_PATH"; then
|
||||
echo "Failed to create virtual environment. Please check your Python installation."
|
||||
exit 1
|
||||
fi
|
||||
@ -33,8 +34,8 @@ fi
|
||||
|
||||
# Activate virtual environment
|
||||
echo "Activating virtual environment..."
|
||||
source "${VENV_PATH}/bin/activate"
|
||||
if [ $? -ne 0 ]; then
|
||||
# shellcheck source=/dev/null
|
||||
if ! source "${VENV_PATH}/bin/activate"; then
|
||||
echo "Failed to activate virtual environment."
|
||||
exit 1
|
||||
fi
|
||||
@ -48,8 +49,7 @@ echo "Checking and installing required packages..."
|
||||
for package in "${REQUIREMENTS[@]}"; do
|
||||
if ! pip show "$package" &> /dev/null; then
|
||||
echo "Installing $package..."
|
||||
pip install "$package"
|
||||
if [ $? -ne 0 ]; then
|
||||
if ! pip install "$package"; then
|
||||
echo "Failed to install $package."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set working directory to script location
|
||||
cd "$(dirname "$0")"
|
||||
cd "$(dirname "$0")" || exit 1
|
||||
|
||||
# Check if Docker daemon is running
|
||||
if ! docker info &>/dev/null; then
|
||||
@ -33,24 +33,18 @@ echo "Starting all applications..."
|
||||
|
||||
# Start temperature anomaly detector - submit to Flink
|
||||
echo "Starting Temperature Anomaly Detector..."
|
||||
cd temperature-anomaly-detector
|
||||
java -jar target/temperature-anomaly-detector-1.0-SNAPSHOT.jar &
|
||||
( cd temperature-anomaly-detector && exec java -jar target/temperature-anomaly-detector-1.0-SNAPSHOT.jar ) &
|
||||
ANOMALY_PID=$!
|
||||
cd ..
|
||||
|
||||
# Start Alert Visualizer
|
||||
echo "Starting Temperature Alert Visualizer..."
|
||||
cd temperature-alert-visualizer
|
||||
java -jar target/temperature-alert-visualizer-1.0-SNAPSHOT.jar &
|
||||
( cd temperature-alert-visualizer && exec java -jar target/temperature-alert-visualizer-1.0-SNAPSHOT.jar ) &
|
||||
VISUALIZER_PID=$!
|
||||
cd ..
|
||||
|
||||
# Start Temperature Generator last
|
||||
echo "Starting Temperature Generator..."
|
||||
cd temperature-generator
|
||||
java -jar target/temperature-generator-1.0-SNAPSHOT.jar &
|
||||
( cd temperature-generator && exec java -jar target/temperature-generator-1.0-SNAPSHOT.jar ) &
|
||||
GENERATOR_PID=$!
|
||||
cd ..
|
||||
|
||||
echo "All applications are running!"
|
||||
echo "Press Ctrl+C to stop all applications"
|
||||
|
||||
@ -1 +1,6 @@
|
||||
g++ -O2 main.cpp -o photon_mapping
|
||||
#!/bin/bash
|
||||
#
|
||||
# Build the photon-mapping demo.
|
||||
set -euo pipefail
|
||||
|
||||
g++ -O2 main.cpp -o photon_mapping
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Create the project virtualenv. Source this file rather than running it if you
|
||||
# want the activation to persist in your shell: `source init.sh`.
|
||||
set -euo pipefail
|
||||
|
||||
pyenv local 3.11
|
||||
python -m venv ./venv
|
||||
source ./venv/bin/activate
|
||||
# shellcheck source=/dev/null
|
||||
source ./venv/bin/activate
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set working directory to script location
|
||||
cd "$(dirname "$0")"
|
||||
cd "$(dirname "$0")" || exit 1
|
||||
|
||||
# Check if Docker daemon is running
|
||||
if ! docker info &>/dev/null; then
|
||||
@ -33,31 +33,23 @@ echo "Starting all applications..."
|
||||
|
||||
# Start Flink job (Anomaly Detector)
|
||||
echo "Starting Anomaly Detector..."
|
||||
cd anomaly-detector
|
||||
java --add-opens java.base/java.time=ALL-UNNAMED -jar target/anomaly-detector-1.0-SNAPSHOT.jar &
|
||||
( cd anomaly-detector && exec java --add-opens java.base/java.time=ALL-UNNAMED -jar target/anomaly-detector-1.0-SNAPSHOT.jar ) &
|
||||
ANOMALY_PID=$!
|
||||
cd ..
|
||||
|
||||
# Start Alert Visualizer
|
||||
echo "Starting Alert Visualizer..."
|
||||
cd alarm-visualizer
|
||||
java --add-opens java.base/java.time=ALL-UNNAMED -jar target/alarm-visualizer-1.0-SNAPSHOT.jar &
|
||||
( cd alarm-visualizer && exec java --add-opens java.base/java.time=ALL-UNNAMED -jar target/alarm-visualizer-1.0-SNAPSHOT.jar ) &
|
||||
ALARM_PID=$!
|
||||
cd ..
|
||||
|
||||
# Start Transaction Consumer/Visualizer
|
||||
echo "Starting Transaction Consumer..."
|
||||
cd kafka-consumer-visualizer
|
||||
java --add-opens java.base/java.time=ALL-UNNAMED -jar target/kafka-consumer-visualizer-1.0-SNAPSHOT.jar &
|
||||
( cd kafka-consumer-visualizer && exec java --add-opens java.base/java.time=ALL-UNNAMED -jar target/kafka-consumer-visualizer-1.0-SNAPSHOT.jar ) &
|
||||
CONSUMER_PID=$!
|
||||
cd ..
|
||||
|
||||
# Start Transaction Producer last
|
||||
echo "Starting Transaction Producer..."
|
||||
cd transaction-simulator
|
||||
java --add-opens java.base/java.time=ALL-UNNAMED -jar target/transaction-simulator-1.0-SNAPSHOT.jar &
|
||||
( cd transaction-simulator && exec java --add-opens java.base/java.time=ALL-UNNAMED -jar target/transaction-simulator-1.0-SNAPSHOT.jar ) &
|
||||
PRODUCER_PID=$!
|
||||
cd ..
|
||||
|
||||
echo "All applications are running!"
|
||||
echo "Press Ctrl+C to stop all applications"
|
||||
|
||||
114
install.sh
Executable file
114
install.sh
Executable file
@ -0,0 +1,114 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ============================================================================
|
||||
# Set this repository up for development.
|
||||
#
|
||||
# Usage:
|
||||
# ./install.sh install tools and wire the git hooks
|
||||
# ./install.sh --check verify only; exit 1 if anything is missing
|
||||
#
|
||||
# Idempotent: a second run reports what is already present and changes nothing.
|
||||
#
|
||||
# It ENDS by verifying, and fails loudly if the gate is not actually runnable.
|
||||
# A warning here would just recreate the bug it exists to prevent: the hooks
|
||||
# were absent from this repo entirely, so every "pre-commit passed" claim
|
||||
# before now was vacuous.
|
||||
# ============================================================================
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly SCRIPT_DIR
|
||||
readonly UTILS_ROOT="${UTILS_ROOT:-$HOME/utils}"
|
||||
|
||||
CHECK_ONLY=0
|
||||
|
||||
log() { printf '==> %s\n' "$*"; }
|
||||
err() { printf 'error: %s\n' "$*" >&2; }
|
||||
|
||||
usage() {
|
||||
grep -E '^# \./install\.sh' "${BASH_SOURCE[0]}" | sed 's/^# //'
|
||||
exit 0
|
||||
}
|
||||
|
||||
# The shared gates are not vendored here on purpose -- they live in one repo so
|
||||
# that every repo enforces the same rule. Without them the hooks cannot run.
|
||||
check_shared_gates() {
|
||||
if [[ ! -d "$UTILS_ROOT" ]]; then
|
||||
err "shared gates not found at $UTILS_ROOT"
|
||||
err " git clone https://github.com/kuhyx/utils \"$UTILS_ROOT\""
|
||||
err " (or set UTILS_ROOT to where it lives)"
|
||||
return 1
|
||||
fi
|
||||
log "shared gates: $UTILS_ROOT"
|
||||
}
|
||||
|
||||
install_tools() {
|
||||
local missing=()
|
||||
command -v shellcheck > /dev/null 2>&1 || missing+=(shellcheck)
|
||||
command -v pre-commit > /dev/null 2>&1 || missing+=(pre-commit)
|
||||
|
||||
if [[ ${#missing[@]} -eq 0 ]]; then
|
||||
log "tools already present: shellcheck, pre-commit"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ $CHECK_ONLY -eq 1 ]]; then
|
||||
err "missing tools: ${missing[*]}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log "installing: ${missing[*]}"
|
||||
if command -v pacman > /dev/null 2>&1; then
|
||||
sudo pacman -S --needed --noconfirm "${missing[@]}"
|
||||
elif command -v apt-get > /dev/null 2>&1; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq "${missing[@]}"
|
||||
else
|
||||
err "no supported package manager; install manually: ${missing[*]}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_hooks() {
|
||||
if [[ $CHECK_ONLY -eq 1 ]]; then
|
||||
[[ -f "${SCRIPT_DIR}/.git/hooks/pre-commit" ]] || {
|
||||
err "git hooks are not installed"
|
||||
return 1
|
||||
}
|
||||
log "git hooks installed"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log "wiring git hooks (pre-commit and pre-push)"
|
||||
( cd "$SCRIPT_DIR" \
|
||||
&& pre-commit install > /dev/null \
|
||||
&& pre-commit install --hook-type pre-push > /dev/null )
|
||||
}
|
||||
|
||||
# The last word. If the gate cannot actually run, say so and exit non-zero.
|
||||
verify() {
|
||||
log "verifying the gate runs"
|
||||
if ! ( cd "$SCRIPT_DIR" && pre-commit run --all-files > /dev/null 2>&1 ); then
|
||||
err "pre-commit run --all-files failed -- the repo is not clean"
|
||||
err "run it directly to see why: pre-commit run --all-files"
|
||||
return 1
|
||||
fi
|
||||
log "OK: all hooks pass"
|
||||
}
|
||||
|
||||
main() {
|
||||
check_shared_gates
|
||||
install_tools
|
||||
install_hooks
|
||||
verify
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--check) CHECK_ONLY=1; shift ;;
|
||||
-h | --help) usage ;;
|
||||
*) err "unknown option: $1"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
main "$@"
|
||||
146
run.sh
Executable file
146
run.sh
Executable file
@ -0,0 +1,146 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ============================================================================
|
||||
# run.sh -- drive this coursework archive.
|
||||
#
|
||||
# ./run.sh check run the full local gate (pre-commit, all files)
|
||||
# ./run.sh install alias for ./install.sh
|
||||
# ./run.sh status probe every course dir, rewrite DOCS-runnability.md
|
||||
# ./run.sh run <dir> actually execute one course project
|
||||
# ./run.sh sync-vendored show the mirrors that gates/vendored.txt feeds
|
||||
#
|
||||
# `status` PROBES: it asks each directory whether its toolchain is present and
|
||||
# never executes the project, so it takes seconds and is safe in CI. Use
|
||||
# `run <dir>` to actually run something. Those are very different commands and
|
||||
# conflating them is how a "status check" turns into 44 builds.
|
||||
# ============================================================================
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly SCRIPT_DIR
|
||||
readonly RUNNABILITY_DOC="${SCRIPT_DIR}/DOCS-runnability.md"
|
||||
|
||||
# Exit codes a per-directory run.sh uses to report itself.
|
||||
readonly EXIT_BLOCKED=78
|
||||
readonly EXIT_NO_CODE=79
|
||||
|
||||
log() { printf '==> %s\n' "$*"; }
|
||||
err() { printf 'error: %s\n' "$*" >&2; }
|
||||
|
||||
usage() {
|
||||
grep -E '^# \./run\.sh' "${BASH_SOURCE[0]}" | sed 's/^# //'
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
course_dirs() {
|
||||
find "${SCRIPT_DIR}/Programming" "${SCRIPT_DIR}/NotProgramming" \
|
||||
-mindepth 1 -maxdepth 1 -type d | sort
|
||||
}
|
||||
|
||||
cmd_check() {
|
||||
log "running the full gate"
|
||||
( cd "$SCRIPT_DIR" && pre-commit run --all-files )
|
||||
}
|
||||
|
||||
cmd_install() { exec "${SCRIPT_DIR}/install.sh" "$@"; }
|
||||
|
||||
# Probe one directory. Prints "<status>\t<detail>"; never executes a project.
|
||||
#
|
||||
# The guard below is load-bearing. Some course dirs already ship their own
|
||||
# run.sh from years ago -- Programming/PSD/run.sh installs packages with sudo
|
||||
# and starts Kafka. Calling one of those with an unknown --probe flag does not
|
||||
# probe anything, it RUNS the project. So a runner is only invoked if it
|
||||
# actually declares --probe; anything else is reported unprobed and left alone.
|
||||
# `timeout` is defence in depth for a script that declares the flag and then
|
||||
# blocks on input anyway.
|
||||
probe_one() {
|
||||
local dir="$1" runner="$1/run.sh"
|
||||
if [[ -x "$runner" ]] && grep -qF -- '--probe' "$runner"; then
|
||||
local out status
|
||||
out="$(timeout 20s "$runner" --probe 2> /dev/null)" && status=0 || status=$?
|
||||
case "$status" in
|
||||
0) printf 'runnable\t%s\n' "${out:-ok}" ;;
|
||||
"$EXIT_BLOCKED") printf 'blocked\t%s\n' "${out:-unknown}" ;;
|
||||
"$EXIT_NO_CODE") printf 'no-code\t%s\n' "${out:-unknown}" ;;
|
||||
*) printf 'error\t%s\n' "probe exited $status" ;;
|
||||
esac
|
||||
return 0
|
||||
fi
|
||||
if [[ -x "$runner" ]]; then
|
||||
printf 'unprobed\tpre-existing run.sh, no --probe support\n'
|
||||
else
|
||||
printf 'unprobed\tno run.sh yet\n'
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_status() {
|
||||
local env_label="${CI:+ci}"
|
||||
env_label="${env_label:-local}"
|
||||
log "probing course directories (${env_label})"
|
||||
|
||||
local tmp
|
||||
tmp="$(mktemp)"
|
||||
trap 'rm -f "${tmp:-}"' RETURN
|
||||
|
||||
local dir rel line
|
||||
while IFS= read -r dir; do
|
||||
rel="${dir#"${SCRIPT_DIR}"/}"
|
||||
line="$(probe_one "$dir")"
|
||||
printf '%s\t%s\n' "$rel" "$line" >> "$tmp"
|
||||
done < <(course_dirs)
|
||||
|
||||
write_runnability_doc "$tmp" "$env_label"
|
||||
log "wrote ${RUNNABILITY_DOC##*/}"
|
||||
awk -F'\t' '{ n[$2]++ } END { for (k in n) printf " %-10s %d\n", k, n[k] }' "$tmp"
|
||||
}
|
||||
|
||||
write_runnability_doc() {
|
||||
local data="$1" env_label="$2"
|
||||
{
|
||||
cat <<'MD'
|
||||
# Runnability
|
||||
|
||||
Generated by `./run.sh status`. Do not edit by hand.
|
||||
|
||||
Status is recorded PER ENVIRONMENT. A directory that is `runnable` locally and
|
||||
`blocked` in CI is the normal case, not drift: the runner has no MATLAB, no
|
||||
Unity and no .NET SDK. CI compares only its own column.
|
||||
|
||||
MD
|
||||
printf '| Course | %s | Detail |\n|---|---|---|\n' "$env_label"
|
||||
awk -F'\t' '{ printf "| `%s` | %s | %s |\n", $1, $2, $3 }' "$data"
|
||||
} > "$RUNNABILITY_DOC"
|
||||
}
|
||||
|
||||
cmd_run() {
|
||||
local target="${1:-}"
|
||||
[[ -n "$target" ]] || { err "run needs a directory"; usage 1; }
|
||||
local runner="${SCRIPT_DIR}/${target}/run.sh"
|
||||
[[ -x "$runner" ]] || { err "no executable run.sh in $target"; return 1; }
|
||||
log "running $target"
|
||||
"$runner"
|
||||
}
|
||||
|
||||
cmd_sync_vendored() {
|
||||
log "gates/vendored.txt declares:"
|
||||
grep -vE '^\s*#|^\s*$' "${SCRIPT_DIR}/gates/vendored.txt" | sed 's/^/ /'
|
||||
printf '\nMirrored into:\n'
|
||||
printf ' ~/utils/file_length/_tables.py VENDORED_SUBPATHS["WUT_Computer_Science"]\n'
|
||||
printf ' pyproject.toml [tool.ruff] exclude (Milestone 4)\n'
|
||||
printf ' pyproject.toml [tool.coverage.run] omit (Milestone 4)\n'
|
||||
}
|
||||
|
||||
main() {
|
||||
case "${1:-}" in
|
||||
check) shift; cmd_check "$@" ;;
|
||||
install) shift; cmd_install "$@" ;;
|
||||
status) shift; cmd_status "$@" ;;
|
||||
run) shift; cmd_run "$@" ;;
|
||||
sync-vendored) shift; cmd_sync_vendored "$@" ;;
|
||||
-h | --help | "") usage ;;
|
||||
*) err "unknown command: $1"; usage 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
main "$@"
|
||||
32
scripts/check_md_naming.sh
Executable file
32
scripts/check_md_naming.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ============================================================================
|
||||
# Fail if any markdown file breaks the shared naming convention.
|
||||
#
|
||||
# Thin delegate to the shared gate in ~/utils, which owns the four namespaces
|
||||
# (README / CLAUDE* / DOCS* / TODO*), the "REMOVE ME AFTER FINISH" marker rule
|
||||
# and the exemption list. Copying that logic here is what lets one repo's idea
|
||||
# of a valid name drift from every other repo's -- so this script only locates
|
||||
# the shared checker and forwards its arguments.
|
||||
#
|
||||
# Usage:
|
||||
# scripts/check_md_naming.sh <file> [<file> ...] # pre-commit passes these
|
||||
# scripts/check_md_naming.sh --all # whole tree, from cwd
|
||||
# ============================================================================
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
readonly SHARED_GATE="${UTILS_ROOT:-$HOME/utils}/scripts/check_md_naming.sh"
|
||||
|
||||
main() {
|
||||
if [[ ! -x "$SHARED_GATE" ]]; then
|
||||
echo "Error: shared markdown-naming gate not found at $SHARED_GATE" >&2
|
||||
echo " Clone github.com/kuhyx/utils to ~/utils, or set" >&2
|
||||
echo " UTILS_ROOT to where it lives." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec bash "$SHARED_GATE" "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Loading…
Reference in New Issue
Block a user