Skip to content

Commit

Permalink
Merge pull request #17 from codacy/refactor
Browse files Browse the repository at this point in the history
Refactor to use new API
  • Loading branch information
rtfpessoa authored Jul 6, 2018
2 parents 0f3cdf9 + 8ba6711 commit 196787b
Show file tree
Hide file tree
Showing 49 changed files with 2,115 additions and 999 deletions.
179 changes: 179 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# CircleCI 2.0 configuration file
version: 2

# Re-usable blocks to reduce boilerplate in job definitions.
references:
host_environment_defaults: &host_environment_defaults
# Customize the JVM maximum heap limit
JAVA_OPTS: -Xmx3200m
docker_environment_defaults: &docker_environment_defaults
# Customize the JVM to read correct memory values
JAVA_OPTS: '-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1'

default_java_job: &default_java_job
docker:
- image: circleci/openjdk:8-jdk
environment:
<<: *docker_environment_defaults
environment:
<<: *host_environment_defaults
working_directory: ~/workdir

restore_source_code: &restore_source_code
restore_cache:
keys:
- source-code-1.0.0-{{ .Branch }}-{{ .Revision }}
- source-code-1.0.0-{{ .Branch }}
- source-code-1.0.0
restore_dependencies: &restore_dependencies
restore_cache:
keys:
- sbt-ivy2-dependencies-1.0.0-{{ checksum "/tmp/dependencies.cache.tmp" }}
- sbt-ivy2-dependencies-1.0.0
restore_build: &restore_build
restore_cache:
keys:
- sbt-build-1.0.0-{{ .Branch }}-{{ .Revision }}
- sbt-build-1.0.0

setup_dependencies_key: &setup_dependencies_key
run:
name: Generate cache key
command: |
shasum build.sbt \
project/plugins.sbt \
project/build.properties \
project/Common.scala \
project/Dependencies.scala > /tmp/dependencies.cache.tmp
jobs:
checkout_code:
<<: *default_java_job
steps:
- *restore_source_code
- checkout
- save_cache:
key: source-code-1.0.0-{{ .Branch }}-{{ .Revision }}
paths:
- ~/workdir

sbt_dependencies:
<<: *default_java_job
steps:
- *restore_source_code
- *setup_dependencies_key
- *restore_dependencies
- run:
name: Resolve dependencies
command: |
sbt update
- save_cache:
paths:
- ~/.ivy2
- ~/.sbt
key: sbt-ivy2-dependencies-1.0.0-{{ checksum "/tmp/dependencies.cache.tmp" }}

compile:
<<: *default_java_job
steps:
- *restore_source_code
- *setup_dependencies_key
- *restore_dependencies
- *restore_build
- run:
name: Compile
command: ./scripts/compile.sh
- save_cache:
paths:
- ~/workdir/target
- ~/workdir/project/target
key: sbt-build-1.0.0-{{ .Branch }}-{{ .Revision }}

test:
<<: *default_java_job
steps:
- *restore_source_code
- *setup_dependencies_key
- *restore_dependencies
- *restore_build
- run:
name: Test
command: ./scripts/test.sh
- run:
name: Store test reports
working_directory: ~/
command: |
mkdir -p ~/coverage-reports/scoverage
cp -f ~/workdir/target/scala-2.12/coverage-report/cobertura.xml ~/coverage-reports/scoverage/results.xml
- store_test_results:
path: ~/coverage-reports
- store_artifacts:
path: ~/workdir/target/scala-2.12/coverage-report
- store_artifacts:
path: ~/workdir/target/scala-2.12/scoverage-report
- store_artifacts:
path: ~/workdir/target/scala-2.12/scoverage-data

lint:
<<: *default_java_job
steps:
- *restore_source_code
- *setup_dependencies_key
- *restore_dependencies
- *restore_build
- run:
name: Lint
command: ./scripts/lint.sh

publish:
<<: *default_java_job
steps:
- *restore_source_code
- *setup_dependencies_key
- *restore_dependencies
- *restore_build
- run:
name: Install AWS CLI
command: |
sudo apt -y update
sudo apt -y install python3-pip
sudo python3 -m pip install awscli
- run:
name: Setup AWS Credentials
command: ./scripts/setup-aws-credentials.sh
- run:
name: Retrieve GPG Keys
command: |
mkdir -p ~/.gnupg
aws s3 sync --profile shared-services --include '*.gpg' s3://$AWS_CREDENTIALS_BUCKET/gnupg/ ~/.gnupg
- run:
name: Publish to Sonatype
command: ./scripts/publish.sh 3.0.$CIRCLE_BUILD_NUM

workflows:
version: 2
test-and-publish:
jobs:
- checkout_code
- sbt_dependencies:
requires:
- checkout_code
- compile:
requires:
- checkout_code
- sbt_dependencies
- test:
requires:
- compile
- lint:
requires:
- compile
- publish:
context: CodacyAWS
requires:
- test
- lint
filters:
branches:
only:
- master
24 changes: 24 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
rules = [
RemoveUnusedImports
RemoveUnusedTerms
ExplicitResultTypes
ExplicitUnit
LeakingImplicitClassVal
MissingFinal
NoAutoTupling
NoInfer
NoValInForComprehension
ProcedureSyntax
Sbt1
]

NoInfer.symbols = [
"java.io.Serializable",
"scala.Any",
"scala.AnyVal",
"scala.Product"
]

ExplicitResultTypes {
unsafeShortenNames = true
}
28 changes: 28 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
style = IntelliJ
maxColumn = 120
docstrings = ScalaDoc
assumeStandardLibraryStripMargin = false
continuationIndent.callSite = 2
continuationIndent.defnSite = 2
align = some
align.tokens = []
align.arrowEnumeratorGenerator = false
align.openParenCallSite = true
align.openParenDefnSite = true
newlines.alwaysBeforeTopLevelStatements = true
newlines.penalizeSingleSelectMultiArgList = true
newlines.alwaysBeforeElseAfterCurlyIf = false
newlines.sometimesBeforeColonInMethodReturnType = true
rewrite.rules = [ AvoidInfix, SortImports, SortModifiers, PreferCurlyFors ]
newlines.alwaysBeforeMultilineDef = true
lineEndings = unix
binPack.literalArgumentLists = true
binPack.parentConstructors = false
spaces.afterKeywordBeforeParen = true
includeCurlyBraceInSelectChains = true
optIn.breakChainOnFirstMethodDot = true
danglingParentheses = true
includeCurlyBraceInSelectChains = true
project.git = true
project.excludeFilters = [".*\\.scala.html$", "target/.*", "modules/admin/target/.*"]

59 changes: 59 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# How to contribute

## Main rules

* Before you open a ticket or send a pull request, [search](https://github.com/codacy/codacy-engine-scala-seed/issues) for previous discussions about the same feature or issue. Add any new details to earlier tickets if you find any.

* If you're proposing a new feature, make sure you create an issue to let other contributors know what you will be working on.

* Before sending a pull request make sure your code is tested.

* Before sending a pull request for a feature, be sure to run tests with `./scripts/test.sh`.

* Use the same coding style as the rest of the codebase, most of the checks can be performed with `./scripts/lint.sh`.

* Use `git rebase` (not `git merge`) to sync your work from time to time with the master branch.

* After creating your pull request make sure the build is passing on [CircleCI](https://circleci.com/gh/codacy/codacy-engine-scala-seed) and that [Codacy](https://www.codacy.com/app/Codacy/codacy-engine-scala-seed) is also confident in the code quality.

## Commit Style

Writing good commit logs is important. A commit log should describe what changed and why.
Follow these guidelines when writing one:

1. The first line should be 50 characters or less and contain a short
description of the change prefixed with the name of the changed
subsystem (e.g. "net: add localAddress and localPort to Socket").
2. Keep the second line blank.
3. Wrap all other lines at 72 columns.

A good commit log can look something like this:

```git-commit
subsystem: explaining the commit in one line
Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc. etc.
The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
72 characters or so. That way `git log` will show things
nicely even when it is indented.
```

### Developer's Certificate of Origin 1.0

By making a contribution to this project, I certify that:

* (a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license indicated
in the file; or
* (b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source license
and I have the right under that license to submit that work with
modifications, whether created in whole or in part by me, under the
same open source license (unless I am permitted to submit under a
different license), as indicated in the file; or
* (c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified it.
Loading

0 comments on commit 196787b

Please sign in to comment.