Compare commits

...

23 Commits

Author SHA1 Message Date
06613ca9b0 Bump version number
All checks were successful
continuous-integration/drone/tag Build is passing
2019-05-01 22:24:20 +02:00
22923e7121 Only run builds on master and tags 2019-05-01 22:23:46 +02:00
49702c22cd Merge branch 'feature/drone-ci'
All checks were successful
continuous-integration/drone/push Build is passing
2019-05-01 22:13:18 +02:00
2da2771218 Add drone badge and remove docker cloud badge 2019-05-01 22:13:06 +02:00
f1ae1b4d59 Enable autotag
All checks were successful
continuous-integration/drone/push Build is passing
2019-05-01 22:08:23 +02:00
80a0afbf53 Upload docker image
All checks were successful
continuous-integration/drone/push Build is passing
2019-05-01 21:56:59 +02:00
751b8e9a6d Build image in CI
Some checks failed
continuous-integration/drone/push Build is failing
2019-05-01 21:31:48 +02:00
6355dce827 Test release build
All checks were successful
continuous-integration/drone/push Build is passing
2019-05-01 18:43:20 +02:00
bd4b8c64ba Fix user
All checks were successful
continuous-integration/drone/push Build is passing
2019-05-01 18:28:16 +02:00
4a69022659 Dummy commit
Some checks failed
continuous-integration/drone/push Build is failing
2019-05-01 18:23:27 +02:00
6f73bbd422 Add drone config
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2019-05-01 18:21:10 +02:00
7b45d72b97 Make worker threads configurable 2019-05-01 16:37:51 +02:00
852a31315d Start 4 worker threads 2019-05-01 16:21:36 +02:00
95f2c987e3 Add travis badge 2019-05-01 13:44:33 +02:00
2d4ad8c58f Clarify binary dependency on git
[ci skip]
2019-05-01 13:42:43 +02:00
beb57036aa Remove TODO from readme 2019-05-01 13:41:02 +02:00
3e507b9b86 Update dependencies 2019-05-01 13:38:57 +02:00
240ffec767 Fix CI config for releases 2019-04-30 17:17:18 +02:00
1bc91a9e41 Bump version number 2019-04-30 16:46:27 +02:00
8ae71cdb5d Merge branch 'feature/case-insensitive-path' 2019-04-30 16:45:43 +02:00
8fc46ab7cc Use all lowercase path names for storage and caching
`Microsoft/vscode` and `microsoft/vscode` point to the same directory
but the repo would have been cloned twice.
2019-04-30 16:45:29 +02:00
1257db4e0d Bump version number 2019-04-30 16:37:40 +02:00
0a67278e46 Fix docker tag for tagged commits 2019-04-30 16:37:04 +02:00
6 changed files with 225 additions and 202 deletions

16
.drone.yml Normal file
View File

@ -0,0 +1,16 @@
kind: pipeline
name: build
steps:
- name: docker
image: plugins/docker
settings:
repo: vbrandl/hits-of-code
auto_tag: true
username:
from_secret: docker_username
password:
from_secret: docker_password
ref:
- refs/heads/master
- refs/tags/v*

View File

@ -12,9 +12,9 @@ variables:
CONTAINER_BUILDER_IMAGE: $CI_REGISTRY_IMAGE:builder-latest
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
CONTAINER_TAG_IMAGE: $CI_REGISTRY_IMAGE:${CI_COMMIT_TAG:1}
before_script:
- export CONTAINER_TAG_IMAGE="$CI_REGISTRY_IMAGE:${CI_COMMIT_TAG:1}"
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build:
@ -42,7 +42,7 @@ release-tag:
stage: release
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_TAG_IMAGE
- docker push $CONTAINER_TAG_IMAGE
only:
- /^v\d+\.\d+\.\d+/

382
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,22 @@
[package]
name = "hoc"
version = "0.2.0"
version = "0.2.3"
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
edition = "2018"
build = "build.rs"
[dependencies]
actix-web = "1.0.0-alpha.4"
actix-web = "1.0.0-beta.2"
badge = "0.2.0"
bytes = "0.4.12"
futures = "0.1.25"
futures = "0.1.26"
git2 = "0.8.0"
lazy_static = "1.3.0"
log = "0.4.6"
number_prefix = "0.3.0"
openssl-probe = "0.1.2"
pretty_env_logger = "0.3.0"
reqwest = "0.9.15"
reqwest = "0.9.16"
serde = "1.0.90"
serde_derive = "1.0.90"
serde_json = "1.0.39"

View File

@ -1,14 +1,15 @@
# Hits-of-Code
[![Hits-of-Code](https://hitsofcode.com/github/vbrandl/hoc)](https://hitsofcode.com/view/github/vbrandl/hoc)
[![Docker build](https://img.shields.io/docker/cloud/build/vbrandl/hits-of-code.svg)](https://hub.docker.com/r/vbrandl/hits-of-code)
[![Drone build](https://drone.vbrandl.net/api/badges/vbrandl/hoc/status.svg)](https://drone.vbrandl.net/vbrandl/hoc)
[![Gitlab build](https://gitlab.com/vbrandl/hoc/badges/master/pipeline.svg)](https://gitlab.com/vbrandl/hoc/pipelines)
[![Travis build](https://travis-ci.org/vbrandl/hoc.svg?branch=master)](https://travis-ci.org/vbrandl/hoc)
Small webservice, that returns a badge of the Hits-of-Code of a git repository, as described by [Yegor
Bugayenko](https://www.yegor256.com/2014/11/14/hits-of-code.html). It is implemented in
[Rust](https://www.rust-lang.org/), using the [actix-web](https://actix.rs/) web framework.
A live version of this API can be found on [hitsofcode.com](https://hitsofcode.com/).
A live version of this webservice can be found on [hitsofcode.com](https://hitsofcode.com/).
## API
@ -47,12 +48,8 @@ from [Docker Hub](https://hub.docker.com/r/vbrandl/hits-of-code)
$ docker run -it --rm vbrandl/hits-of-code --help
```
When running the binary directly, you need a git binary in your `PATH`.
## TODO
* [x] Customization of badges (e.g. colors)
* [x] Support other platforms beside GitHub (GitLab and Bitbucket)
* [ ] Allow exclusion of certain files/globs from the HoC count
## License

View File

@ -101,6 +101,9 @@ struct Opt {
#[structopt(short = "d", long = "domain", default_value = "hitsofcode.com")]
/// Interface to listen on
domain: String,
#[structopt(short = "w", long = "workers", default_value = "4")]
/// Number of worker threads
workers: usize,
}
fn pull(path: impl AsRef<Path>) -> Result<(), Error> {
@ -204,7 +207,7 @@ fn hoc_request<T: Service>(
state: web::Data<Arc<State>>,
data: web::Path<(String, String)>,
) -> Result<HocResult, Error> {
let repo = format!("{}/{}", data.0, data.1);
let repo = format!("{}/{}", data.0.to_lowercase(), data.1.to_lowercase());
let service_path = format!("{}/{}", T::domain(), repo);
let path = format!("{}/{}", state.repos, service_path);
let file = Path::new(&path);
@ -348,6 +351,7 @@ fn main() -> std::io::Result<()> {
.service(web::resource("/view/bitbucket/{user}/{repo}").to(overview::<Bitbucket>))
.default_service(web::resource("").route(web::get().to(p404)))
})
.workers(OPT.workers)
.bind(interface)?
.run()
}