
    # THIS FILE IS AUTOGENERATED BY THE DEVENVSHELL
    # DO NOT EDIT THIS FILE MANUALLY
    # INSTEAD EDIT THE DEVENVSHELL CONFIGURATION FILE devenv.nix 
    # AND OPEN A SHELL WITH THE COMMAND devenv shell
    #
    # Information about the task runner can be found here:
    # https://taskfile.dev

    version: '3'

    tasks:
      default:
        cmds:
          - task --list
        silent: true
        
      test:
        desc: Execute unit tests in Go.
        cmds:
          - echo "Execute unit tests in Go."
          - go test -cover -v ./...
          - go test -bench -v ./...
          - go test -race -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."
          - go install github.com/google/addlicense@latest
          - addlicense -c "schukai GmbH" -s -l "AGPL-3.0" ./*.go
        silent: true
        
      check-licenses:
        desc: Check license headers of Go files.
        silent: true
        cmds:
          - go-licenses save "$(get-go-default-packages)"  --ignore "gitlab.schukai.com"  --force --save_path ${DEVENV_ROOT}/licenses/

      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

      commit:
        desc: Commit changes to the repository.
        aliases:
          - c
          - ci
          - git-commit
        cmds:
          - do-git-commit
    EOF

    cat <<'EOF' > .gitlab-ci.yml

    # THIS FILE IS AUTOGENERATED BY THE DEVENVSHELL
    # DO NOT EDIT THIS FILE MANUALLY
    # INSTEAD EDIT THE DEVENVSHELL CONFIGURATION FILE devenv.nix
    # AND OPEN A SHELL WITH THE COMMAND devenv shell
    #

    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
      DOCKER_HOST: unix:///var/run/docker.sock
      GIT_DEPTH: 10

    stages:
      - test
      - deploy 

    before_script:
      - unset DOCKER_TLS_VERIFY
      - nix shell nixpkgs#coreutils -c mkdir -p /certs/client/
      - nix shell nixpkgs#coreutils -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
      - env
      - nix shell nixpkgs#docker-client -c docker info

    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   
    EOF

       
        

export PS1="\[\e[0;34m\](devenv)\[\e[0m\] ${PS1-}"

# set path to locales on non-NixOS Linux hosts
if [ -z "${LOCALE_ARCHIVE-}" ]; then
  export LOCALE_ARCHIVE=/nix/store/0g0c6sbrqxmywr636qzxni44wrqqrbdp-glibc-locales-2.37-45/lib/locale/locale-archive
fi


# note what environments are active, but make sure we don't repeat them
if [[ ! "${DIRENV_ACTIVE-}" =~ (^|:)"$PWD"(:|$) ]]; then
  export DIRENV_ACTIVE="$PWD:${DIRENV_ACTIVE-}"
fi

# devenv helper
if [ ! type -p direnv &>/dev/null && -f .envrc ]; then
  echo "You have .envrc but direnv command is not installed."
  echo "Please install direnv: https://direnv.net/docs/installation.html"
fi

mkdir -p .devenv
rm -f .devenv/profile
ln -s /nix/store/5ji01c0jsm65gs0xmn0mfnjjphgdgsnz-devenv-profile .devenv/profile

