diff --git a/.circleci/app.ignore b/.circleci/app.ignore deleted file mode 100644 index 35903ae..0000000 --- a/.circleci/app.ignore +++ /dev/null @@ -1,5 +0,0 @@ -README.md -LICENSE -renovate.json -.pre-commit-config.yaml -.github/ diff --git a/.circleci/app.yml b/.circleci/app.yml deleted file mode 100644 index 8a7071a..0000000 --- a/.circleci/app.yml +++ /dev/null @@ -1,133 +0,0 @@ -version: 2.1 - -executors: - default: - docker: - - image: cimg/base:stable - -commands: - increment-minor-tag: - steps: - - run: - name: Autoincrement repository's latest tag minor version - command: |+ - git fetch --all --tags - RES="$(git show-ref --tags)" - - if [ -z "$RES" ]; then - NEW_TAG="v1.0.0" - else - mapfile -d " " -t LATEST_TAG < <(git tag | sort -V | tail -1 | sed 's/\./ /g') - - if [ "${#LATEST_TAG[@]}" -ne 3 ]; then - printf "Must follow semver convention /v?[0-9]{3}.[0-9]{3}.[0-9]{3}/ to parse.\\n" 1>&2 - exit 1 - fi - - one="${LATEST_TAG[0]//v/}" - two="${LATEST_TAG[1]}" - three="${LATEST_TAG[2]}" - - # Increment versions mod 1k. - if [ "$three" == "999" ]; then - if [ "$two" == "999" ]; then - three=0 - two=0 - ((one++)) - else - ((two++)) - three=0 - fi - elif [ "$two" == "999" ] && [ "$three" == "999" ]; then - ((one++)) - two=0 - else - ((three++)) - fi - - NEW_TAG="v${one}.${two}.${three}" - fi - - git tag "$NEW_TAG" - git push origin "$NEW_TAG" - - release: - steps: - - run: - name: Generate release - command: |+ - # Get latest tag. - git fetch --all --tags - export LATEST_TAG="$(git tag | sort -V | tail -1)" - echo "$LATEST_TAG" - - # Generate release from tag. - echo "$GITHUB_TOKEN" | gh auth login --with-token 2>/dev/null || true - gh release create "$LATEST_TAG" --generate-notes - -jobs: - autoincrement-minor-tag: - executor: default - resource_class: small - steps: - - checkout - - add_ssh_keys: - fingerprints: - - FIXME - - increment-minor-tag - - generate-release: - executor: default - resource_class: small - steps: - - checkout - - run: - name: Install gh CLI - command: |+ - wget https://github.com/cli/cli/releases/download/v2.9.0/gh_2.9.0_linux_amd64.deb -O gh.deb - sudo dpkg -i gh.deb - - release - - hello: - executor: default - resource_class: small - steps: - - run: - name: Hello - command: echo hello - -workflows: - version: 2 - - on-tag: - jobs: - - hello: - filters: - branches: - ignore: /.*/ - tags: - only: /^v[0-9]+\.[0-9]+\.[0-9]+$/ - - on-merge: - jobs: - # Auto-increment minor tag to kick off on-tag workflow. - - autoincrement-minor-tag: - filters: - branches: - only: master - - # Generate a release from the latest tag. - - generate-release: - context: github - filters: - branches: - only: master - requires: - - autoincrement-minor-tag - - on-commit: - jobs: - - hello: - filters: - branches: - ignore: master diff --git a/.circleci/config.yml b/.circleci/config.yml index 6afe1c8..5381f79 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,15 +3,12 @@ version: 2.1 setup: true orbs: - dynamic: bjd2385/dynamic-continuation@3.6.12 + dynamic: bjd2385/dynamic-continuation@3.9.1 workflows: version: 2 default: jobs: - - dynamic/extend: - context: orb-publishing - modules: | - . - scripts + - dynamic/continue: + context: orb-publishing \ No newline at end of file diff --git a/.circleci/scripts.yml b/.circleci/scripts.yml index 36e7619..35c45f7 100644 --- a/.circleci/scripts.yml +++ b/.circleci/scripts.yml @@ -14,7 +14,7 @@ workflows: on-commit: jobs: - shellcheck/check: - dir: ./src/scripts + dir: . exclude: SC2148 filters: branches: diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index cf991f9..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -# These are supported funding model platforms - -ko_fi: bjd2385 diff --git a/renovate.json b/.github/renovate.json similarity index 100% rename from renovate.json rename to .github/renovate.json diff --git a/.github/settings.yml b/.github/settings.yml index 6b58dba..a68c2d2 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -1,10 +1,10 @@ _extends: .github repository: - name: base - description: Base repository with default settings and configs - homepage: github.com + name: directory-anarchy + description: A directory traversal game that teaches you Bash + homepage: anarchy.aperiodicity.com # A comma-separated list of topics to set on the repository topics: settings - private: false + private: false \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dce2771..654dda3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,23 +1,38 @@ +fail_fast: true repos: + # Requires hadolint binary on local machine. + - repo: https://github.com/hadolint/hadolint + rev: v2.12.0 + hooks: + - id: hadolint + args: + - --config + - config/.hadolint.yaml + - Dockerfile + - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.4.0 hooks: - id: trailing-whitespace - args: [--markdown-linebreak-ext=md] - - id: end-of-file-fixer - - id: check-yaml - id: check-added-large-files - - id: check-merge-conflict + args: [--maxkb=10000, --enforce-all] + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: mixed-line-ending - - repo: https://github.com/bjd2385/circleci-orb-pre-commit-hook - rev: v1.2.0 + - repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 3.0.0 hooks: - - id: circleci-orb-validate + - id: shellcheck args: - - src # Target the src/ directory. - - "true" # Enable pre-pack prior to validation. + - -x - - repo: https://github.com/bjd2385/circleci-config-pre-commit-hook - rev: v1.0.3 + - repo: https://github.com/emmeowzing/dynamic-continuation-orb + rev: v3.6.8 hooks: - id: circleci-config-validate + + - repo: https://github.com/premiscale/pre-commit-hooks + rev: v0.0.7 + hooks: + - id: msg-issue-prefix \ No newline at end of file diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..062a1e2 --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +shellcheck 0.10.0 +hadolint 2.12.0 \ No newline at end of file diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md new file mode 100644 index 0000000..9db7d2a --- /dev/null +++ b/CONTRIBUTE.md @@ -0,0 +1,29 @@ +# Contributing + +To contribute to this repository, start by installing the necessary dependencies and following the build steps, below! + +## Dependencies + +Install asdf, followed by executing the dependencies script. + +```shell +./scripts/dependencies.sh +``` + +This script will install all necessary tools and their versions as defined in the `.tool-versions`-file at the root of this repository. + +### Docker + +This project has primarily been developed on Docker. Please have a suitable version installed on your machine (25 and later). Please open an Issue in this repository if you have any issues running this container image. + +## Build + +Run the following Docker build and run commands to execute this codebase. + +```shell +DOCKER_BUILDKIT=1 docker build --platform="linux/[amd64|arm64]" . -t directory-anarchy:latest +docker run -it -e DEBUG=true -n directory-anarchy-game directory-anarchy:latest +``` + +### pre-commit + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ecbcbba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +ARG REGISTRY=docker.io +ARG IMAGE=ubuntu +ARG TAG=22.04 + +FROM ${REGISTRY}/${IMAGE}:${TAG} + +SHELL [ "/bin/bash", "-c" ] + +ENV DEBUG=false + +# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys +LABEL org.opencontainers.image.description "Directory anarchy game" +LABEL org.opencontainers.image.licenses "MIT" +LABEL org.opencontainers.image.authors "Emma Doyle , Willow Ahrens " +LABEL org.opencontainers.image.documentation "https://anarchy.aperiodicity.com" + +USER root + +# apt list -a bash && apt install -y \ +RUN apt update \ + && rm -rf /var/apt/lists/* \ + && groupadd anarchists --gid 1001 \ + && useradd -rm -d /opt/anarchy -s /bin/bash -g anarchists -u 1001 anarchist + +WORKDIR /opt/anarchy + +COPY --chown=anarchist:anarchists scripts/cmd.sh . + +USER anarchist + +CMD [ "./cmd.sh" ] \ No newline at end of file diff --git a/config/.hadolint.yaml b/config/.hadolint.yaml new file mode 100644 index 0000000..88924cd --- /dev/null +++ b/config/.hadolint.yaml @@ -0,0 +1,10 @@ +ignored: + - DL3008 + - DL3015 + - DL4006 + - DL3027 + - DL3013 + - DL3042 + - SC1091 + - DL3033 + - DL3032 \ No newline at end of file diff --git a/scripts/.placeholder b/scripts/.placeholder deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/cmd.sh b/scripts/cmd.sh new file mode 100755 index 0000000..1803474 --- /dev/null +++ b/scripts/cmd.sh @@ -0,0 +1,2 @@ +#! /usr/bin/env bash +# Start the game. \ No newline at end of file diff --git a/scripts/dependencies.sh b/scripts/dependencies.sh new file mode 100755 index 0000000..11243a8 --- /dev/null +++ b/scripts/dependencies.sh @@ -0,0 +1,7 @@ +#! /usr/bin/env bash +# Install all dependencies for developing this project. + +asdf plugin add hadolint https://github.com/looztra/asdf-hadolint.git +asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git + +asdf install \ No newline at end of file