Skip to content
Snippets Groups Projects
Verified Commit 531a6d7c authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: init struct

parent 584f47e6
No related branches found
No related tags found
No related merge requests found
.envrc 0 → 100644
source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0="
use devenv
\ No newline at end of file
# Devenv
.devenv*
devenv.local.nix
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml
image: docker-registry.schukai.com:443/nixos-ci-devenv:latest
services:
- docker:dind
variables:
# The repo name as used in
# https://github.com/nix-community/NUR/blob/master/repos.json
NIXOS_VERSION: "23.05"
NIXPKGS_ALLOW_UNFREE: "1"
NIXPKGS_ALLOW_INSECURE: "1"
DOCKER_DRIVER: overlay2
GIT_DEPTH: 10
stages:
- test
- deploy
before_script:
- nix shell nixpkgs#coreutils-full -c mkdir -p /certs/client/
- nix shell nixpkgs#coreutils-full -c ln -fs /etc/ssl/certs/ca-bundle.crt /certs/client/ca.pem
- echo > .env-gitlab-ci
- variables=("HOME=$HOME" "CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME" "CI_REPOSITORY_URL=$CI_REPOSITORY_URL" "GITLAB_TOKEN=$GITLAB_TOKEN" "CI_JOB_TOKEN=$CI_JOB_TOKEN" "GITLAB_USER_EMAIL=$GITLAB_USER_EMAIL" "GITLAB_USER_NAME=\"$GITLAB_USER_NAME\"" "CI_REGISTRY_USER=$CI_REGISTRY_USER" "CI_PROJECT_ID=$CI_PROJECT_ID" "CI_PROJECT_DIR=$CI_PROJECT_DIR" "CI_API_V4_URL=$CI_API_V4_URL" "CI_PROJECT_NAME=$CI_PROJECT_NAME" "CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA"); for var in "${variables[@]}"; do echo "$var" >> .env-gitlab-ci; done
- cat .env-gitlab-ci
after_script:
- if [ -f .env-gitlab-ci ]; then rm .env-gitlab-ci; fi
test:
stage: test
tags:
- nixos
script:
- devenv shell test-lib
cache:
- key: nixos
paths:
- /nix/store
artifacts:
paths:
- dist
deploy:
stage: deploy
tags:
- nixos
script:
- devenv shell -c deploy-lib
when: on_success
cache:
- key: nixos
paths:
- /nix/store
artifacts:
paths:
- dist
LICENSE 0 → 100644
This diff is collapsed.
# Watch
## Wathc
## What does this library?
This library allows you to monitor and control files and define actions for changes.
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
## Installation
```shell
go get gitlab.schukai.com/oss/libraries/go/utilities/watch
```
cd existing_repo
git remote add origin https://gitlab.schukai.com/oss/libraries/go/utilities/watch.git
git branch -M master
git push -uf origin master
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.schukai.com/oss/libraries/go/utilities/watch/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
**Note:** This library uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Usage
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Contributing
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
Merge requests are welcome. For major changes, please open an issue first to discuss what
you would like to change. **Please make sure to update tests as appropriate.**
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
Versioning is done with [SemVer](https://semver.org/).
Changelog is generated with [git-chglog](https://github.com/git-chglog/git-chglog#git-chglog)
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
Commit messages should follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
Messages are started with a type, which is one of the following:
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
- **feat**: A new feature
- **fix**: A bug fix
- **doc**: Documentation only changes
- **refactor**: A code change that neither fixes a bug nor adds a feature
- **perf**: A code change that improves performance
- **test**: Adding missing or correcting existing tests
- **chore**: Other changes that don't modify src or test files
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
The footer would be used for a reference to an issue or a breaking change.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
A commit that has a footer `BREAKING CHANGE:`, or appends a ! after the type/scope,
introduces a breaking API change (correlating with MAJOR in semantic versioning).
A BREAKING CHANGE can be part of commits of any type.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
the following is an example of a commit message:
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
```text
feat: add 'extras' field
```
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
[AGPL-3.0](https://choosealicense.com/licenses/agpl-3.0/)
# https://taskfile.dev
version: '3'
tasks:
default:
cmds:
- task --list-all
silent: true
test:
desc: Execute unit tests in Go.
cmds:
- echo "Execute unit tests in Go."
- go test -cover -v ./...
test-fuzz:
desc: Conduct fuzzing tests.#
cmds:
- echo "Conduct fuzzing tests."
- go test -v -fuzztime=30s -fuzz=Fuzz ./...
add-licenses:
desc: Attach license headers to Go files.
cmds:
- echo "Attach license headers to Go files."
- addlicense -c "schukai GmbH" -s -l "AGPL-3.0" ./*.go
silent: true
check:
desc: Confirm repository status.
cmds:
- git diff-index --quiet HEAD || (echo "There are uncommitted changes after running make. Please commit or stash them before running make."; exit 1)
silent: true
build:
desc: Compile the application,
aliases:
- b
vars:
DEVENV_ROOT:
sh: echo "$DEVENV_ROOT"
cmds:
- devenv shell build-app
sources:
- source/**/*.go
- source/**/*.mod
- dist/**
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1694097209,
"narHash": "sha256-gQmBjjxeSyySjbh0yQVBKApo2KWIFqqbRUvG+Fa+QpM=",
"owner": "cachix",
"repo": "devenv",
"rev": "7a8e6a91510efe89d8dcb8e43233f93e86f6b189",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1694048570,
"narHash": "sha256-PEQptwFCVaJ+jLFJgrZll2shQ9VI/7xVhrCYkJo8iIw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "4f77ea639305f1de0a14d9d41eef83313360638c",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1694048570,
"narHash": "sha256-PEQptwFCVaJ+jLFJgrZll2shQ9VI/7xVhrCYkJo8iIw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4f77ea639305f1de0a14d9d41eef83313360638c",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-23.05",
"type": "indirect"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1692274144,
"narHash": "sha256-BxTQuRUANQ81u8DJznQyPmRsg63t4Yc+0kcyq6OLz8s=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "7e3517c03d46159fdbf8c0e5c97f82d5d4b0c8fa",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks",
"version": "version"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"version": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1690668568,
"narHash": "sha256-jzixQKFFW4oxO0S4GYqbkFCXzhBd6com6Z9+MtVKakU=",
"ref": "refs/heads/master",
"rev": "3838f03165b726e47d586c04a1821749375e1001",
"revCount": 37,
"type": "git",
"url": "https://gitlab.schukai.com/oss/utilities/version.git"
},
"original": {
"type": "git",
"url": "https://gitlab.schukai.com/oss/utilities/version.git"
}
}
},
"root": "root",
"version": 7
}
{ pkgs, inputs, phps, lib, config, modulesPath,... }:
{
# https://devenv.sh/packages/
packages = [
inputs.version.defaultPackage."${builtins.currentSystem}"
pkgs.git
pkgs.gcc12
pkgs.go-task
pkgs.blackbox
pkgs.blackbox-terminal
pkgs.jq
pkgs.delve
pkgs.gdlv
pkgs.wget
pkgs.glab
pkgs.unixtools.xxd
pkgs.libffi
pkgs.zlib
pkgs.procps
pkgs.php81Extensions.xdebug
pkgs.ranger
pkgs.meld
pkgs.gnused
pkgs.coreutils-full
pkgs.gnugrep
pkgs.gnumake
pkgs.util-linux
pkgs.httpie
pkgs.netcat
pkgs.memcached
pkgs.fd
];
# https://devenv.sh/languages/
# languages.nix.enable = true;
languages = {
go = { enable = true; };
};
difftastic.enable = true;
# This script is executed when the app is built
# You can use it to build the app
scripts.test-lib.exec = ''
#!${pkgs.bash}/bin/bash
#set -euo pipefail
set -x
PATH="''${PATH}":${pkgs.coreutils}/bin
PATH="''${PATH}":${pkgs.findutils}/bin
PATH="''${PATH}":${pkgs.jq}/bin/
PATH="''${PATH}":${pkgs.rsync}/bin/
PATH="''${PATH}":${pkgs.bash}/bin/
PATH="''${PATH}":${pkgs.curl}/bin/
PATH="''${PATH}":${pkgs.moreutils}/bin/
PATH="''${PATH}":${pkgs.gnutar}/bin
PATH="''${PATH}":${pkgs.gzip}/bin/
PATH="''${PATH}":${pkgs.procps}/bin/
PATH="''${PATH}":${pkgs.exa}/bin/
PATH="''${PATH}":${pkgs.git}/bin/
PATH="''${PATH}":${pkgs.gnugrep}/bin/
PATH="''${PATH}":${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/
export -f PATH
task test
'';
# This scritp is used to deploy the app to the gitlab registry
# It is used by the gitlab-ci.yml file
# The environment variables are set in the gitlab project settings
scripts.deploy-lib.exec = ''
#!${pkgs.bash}/bin/bash
PATH="''${PATH}":${pkgs.coreutils}/bin
PATH="''${PATH}":${pkgs.jq}/bin/
PATH="''${PATH}":${pkgs.curl}/bin/
PATH="''${PATH}":${pkgs.moreutils}/bin/
PATH="''${PATH}":${pkgs.gnutar}/bin
PATH="''${PATH}":${pkgs.gzip}/bin/
PATH="''${PATH}":${pkgs.exa}/bin/
PATH="''${PATH}":${pkgs.git}/bin/
PATH="''${PATH}":${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/
export PATH
if [[ -f .env-gitlab-ci ]]; then
source .env-gitlab-ci
rm .env-gitlab-ci
fi
set -x
## if $HOME not set, set it to current directory
if [[ -z "''${HOME}" ]]; then
HOME=$(pwd)
fi
export HOME
git config user.email "''${GITLAB_USER_EMAIL}"
git config user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}"
git config pull.rebase true
git config http.sslVerify "false"
git remote set-url origin https://pad:''${GITLAB_TOKEN}@''${CI_REPOSITORY_URL#*@}
git fetch --all --tags --unshallow
git reset --hard origin/master
git checkout $CI_COMMIT_REF_NAME
git pull origin $CI_COMMIT_REF_NAME
if [ ! -z "''${CI_PROJECT_DIR}" ]; then
echo "CI_PROJECT_DIR is set, using it as project root."
project_root=$(realpath "''${CI_PROJECT_DIR}")/
elif [ ! -z "''${DEVENV_ROOT}" ]; then
echo "DEVENV_ROOT is set, using it as project root."
project_root=$(realpath "''${DEVENV_ROOT}")/
else
echo "Error: DEVENV_ROOT or CI_PROJECT_DIR environment variables are not set."
exit 1
fi
if [ ! -d "''${project_root}" ]; then
echo "Error: Project root directory does not seem to be valid."
echo "Check the DEVENV_ROOT or CI_PROJECT_DIR environment variables."
exit 1
fi
if [ -z "'CI_JOB_TOKEN" ]; then
echo "Error: CI_JOB_TOKEN variable is not set."
exit 1
fi
git --no-pager log --decorate=short --pretty=oneline
gitVersion=v$(version predict)
git tag -a $gitVersion -m"chore: bump version"
git --no-pager log --decorate=short --pretty=oneline
git push -o ci.skip origin ''${CI_COMMIT_REF_NAME} --tags
echo "done"
'';
}
inputs:
nixpkgs:
url: github:nixos/nixpkgs/nixos-23.05
version:
url: git+https://gitlab.schukai.com/oss/utilities/version.git
flake: true
go.mod 0 → 100644
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment