allcups-itrally-2020-task

module
v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2021 License: MIT

README

IT RALLY 2020 HighLoad Cup: The task

CI/CD CircleCI Project Layout

Service implementing the task for IT RALLY 2020 HighLoad Cup (runs on All Cups platform).

Table of Contents

Development

Requirements
  • Go 1.15
  • Docker 19.03+
  • Docker Compose 1.25+
  • Tools used to build/test project (feel free to install these tools using your OS package manager or any other way, but please ensure they've required versions):
GO111MODULE=off go get -u github.com/myitcv/gobin
curl -sSfL https://github.com/hadolint/hadolint/releases/download/v1.19.0/hadolint-$(uname)-x86_64 | sudo install /dev/stdin /usr/local/bin/hadolint
curl -sSfL https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.$(uname).x86_64.tar.xz | sudo tar xJf - -C /usr/local/bin --strip-components=1 shellcheck-v0.7.1/shellcheck
Setup
  1. After cloning the repo copy env.sh.dist to env.sh.
  2. Review env.sh and update for your system as needed.
  3. It's recommended to add shell alias alias dc="if test -f env.sh; then source env.sh; fi && docker-compose" and then run dc instead of docker-compose - this way you won't have to run source env.sh after changing it.
Usage

To develop this project you'll need only standard tools: go generate, go test, go build, docker build. Provided scripts are for convenience only.

  • Always load env.sh in every terminal used to run any project-related commands (including go test): source env.sh.
    • When env.sh.dist change (e.g. by git pull) next run of source env.sh will fail and remind you to manually update env.sh to match current env.sh.dist.
  • go generate ./... - do not forget to run after making changes related to auto-generated code
  • go test ./... - test project (excluding integration tests), fast
  • ./scripts/test - thoroughly test project, slow
  • ./scripts/test-ci-circle - run tests locally like CircleCI will do
  • ./scripts/cover - analyse and show coverage
  • ./scripts/build - build docker image and binaries in bin/
    • Then use mentioned above dc (or docker-compose) to run and control the project.
    • Access project at host/port(s) defined in env.sh.

As this project isn't a real service but a one-shot task which is supposed to handle single user for a fixed period of time and then finish, if you'll use dc up to start it while development then you should use dc up --force-recreate to ensure each time it'll start with clean state. An alternative is to just run bin/task or use docker run.

Deploy

docker run --name=hlcup2020_task -i -t --rm \
    -e HLCUP2020_DIFFICULTY=normal \
    -v hlcup2020-task:/home/app/var/data \
    ghcr.io/djarvur/allcups-itrally-2020-task:1.1.0

Directories

Path Synopsis
api
openapi
Package api contains OpenAPI spec and code generated by go-swagger.
Package api contains OpenAPI spec and code generated by go-swagger.
openapi/restapi
Package restapi HighLoad Cup 2020
Package restapi HighLoad Cup 2020
cmd
digger_basic
Command digger_basic implements the most trivial and dumb client which can be implemented in an hour.
Command digger_basic implements the most trivial and dumb client which can be implemented in an hour.
task
Service implementing the task for IT RALLY 2020 HighLoad Cup (runs on All Cups platform).
Service implementing the task for IT RALLY 2020 HighLoad Cup (runs on All Cups platform).
internal
app
Package app provides business logic.
Package app provides business logic.
app/game
Package game implements treasure hunting game.
Package game implements treasure hunting game.
app/resource
Package resource implements virtual resources, which simulate some real-world resources without actually consuming them.
Package resource implements virtual resources, which simulate some real-world resources without actually consuming them.
config
Package config provides configurations for subcommands.
Package config provides configurations for subcommands.
dal
Package dal implements Data Access Layer using in-memory DB.
Package dal implements Data Access Layer using in-memory DB.
srv/openapi
Package openapi implements OpenAPI server.
Package openapi implements OpenAPI server.
pkg
cobrax
Package cobrax contains helpers to use with github.com/spf13/cobra.
Package cobrax contains helpers to use with github.com/spf13/cobra.
concurrent
Package concurrent provide a helpers to setup, start and shutdown a lot of services in parallel.
Package concurrent provide a helpers to setup, start and shutdown a lot of services in parallel.
def
Package def provides default values for both commands and tests.
Package def provides default values for both commands and tests.
netx
Package netx contains experimental helpers related to network.
Package netx contains experimental helpers related to network.
serve
Package serve provides helpers to start and shutdown network services.
Package serve provides helpers to start and shutdown network services.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL