diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..7ceab75 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,36 @@ +version: 2.1 + +orbs: + codacy: codacy/base@10.8.0 + codacy_plugins_test: codacy/plugins-test@1.1.1 + +workflows: + compile_test_deploy: + jobs: + - codacy/checkout_and_version + - codacy/shell: + name: publish_docker_local + cmd: | + docker build -t $CIRCLE_PROJECT_REPONAME:latest . + docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest + persist_to_workspace: true + requires: + - codacy/checkout_and_version + - codacy_plugins_test/run: + name: plugins_test + run_multiple_tests: true + requires: + - publish_docker_local + - codacy/publish_docker: + context: CodacyDocker + requires: + - plugins_test + filters: + branches: + only: + - master + - codacy/tag_version: + name: tag_version + context: CodacyAWS + requires: + - codacy/publish_docker \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8e90704 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM golang:1.21.0-alpine3.18 as builder + +WORKDIR /src +RUN apk add python3 py3-pip +RUN python3 -m pip install semgrep + +ADD . . +RUN go build -o bin/codacy-semgrep + +FROM alpine:3.18 + +ENV PATH="/go/bin:${PATH}" +COPY --from=builder /go /go +COPY --from=builder /src/bin /dist/bin +# COPY docs/ /docs/ + +RUN adduser -u 2004 -D docker +# RUN chown -R docker:docker /docs + +CMD [ "/dist/bin/codacy-semgrep" ] diff --git a/README.md b/README.md index f8e8ec1..39dce80 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,58 @@ -# codacy-public-template +# Codacy Semgrep -Template repository for new public repositories. +This is the docker engine we use at Codacy to have [Semgrep](https://github.com/returntocorp/semgrep) support. -## GitHub actions +## Usage -This repository has the common GitHub actions that we want to have accross all of our public repositories. -They should be kept at `.github/workflows` +You can create the docker by doing: + + ```bash + docker build -t codacy-semgrep:latest . + ``` + +The docker is ran with the following command: + + ```bash + docker run -it -v $srcDir:/src codacy-semgrep:latest + ``` + +## Generate Docs + + 1. Update the version in `go.mod` + 2. Install the dependencies: + +```bash +go mod download +``` + + 3. Run the DocGenerator: + +```bash +go run ./doc-generator.go &&\ +scala-cli doc-generator.sc +``` + +## Test + +We use the [codacy-plugins-test](https://github.com/codacy/codacy-plugins-test) to test our external tools integration. +You can follow the instructions there to make sure your tool is working as expected. + +## What is Codacy? + +[Codacy](https://www.codacy.com/) is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews. + +### Among Codacy’s features + +- Identify new Static Analysis issues +- Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories) +- Auto-comments on Commits and Pull Requests +- Integrations with Slack, HipChat, Jira, YouTrack +- Track issues in Code Style, Security, Error Proneness, Performance, Unused Code and other categories + +Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity. + +Codacy supports PHP, Python, Ruby, Java, JavaScript, and Scala, among others. + +### Free for Open Source + +Codacy is free for Open Source projects. diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..ecd9fe0 --- /dev/null +++ b/go.mod @@ -0,0 +1,11 @@ +module codacy.com/codacy-gorevive + +go 1.20 + +require github.com/codacy/codacy-engine-golang-seed v1.0.0 + +require ( + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/stretchr/testify v1.8.4 // indirect + golang.org/x/sys v0.13.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..c02bd5c --- /dev/null +++ b/go.sum @@ -0,0 +1,24 @@ +github.com/codacy/codacy-engine-golang-seed v1.0.0 h1:XK3JUglfuJbmzBSorDKaDKUX1yZIgTcvBVAO7IHWeVQ= +github.com/codacy/codacy-engine-golang-seed v1.0.0/go.mod h1:SX3/fSiePVt1G8IsjTq3a4Zk2EF/VeEYJAX/R+HpyDY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/main.go b/main.go new file mode 100644 index 0000000..1ac4e66 --- /dev/null +++ b/main.go @@ -0,0 +1,9 @@ +package main + +// import codacy "github.com/codacy/codacy-engine-golang-seed" + +func main() { + // implementation := NewImplementation() + + // codacy.StartTool(implementation) +}