Skip to content

Commit 8c39cb0

Browse files
Initialize staging
0 parents  commit 8c39cb0

16 files changed

+320
-0
lines changed
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Code Merge Workflow
2+
3+
on:
4+
push:
5+
branches: ["staging"]
6+
pull_request:
7+
branches: ["staging", "master"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
check-code-formatting:
14+
name: Check Code Formatting
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Set up JDK 11
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: '11'
22+
distribution: 'temurin'
23+
cache: 'sbt'
24+
- name: Scalafmt Check
25+
run: sbt scalafmtCheckAll
26+
run-unit-tests:
27+
name: Run Unit Tests
28+
needs: check-code-formatting
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v3
32+
- name: Set up JDK 11
33+
uses: actions/setup-java@v3
34+
with:
35+
java-version: '11'
36+
distribution: 'temurin'
37+
cache: 'sbt'
38+
- name: Run Unit Tests
39+
run: sbt test
40+
run-integration-tests:
41+
name: Run Integration Tests
42+
needs: check-code-formatting
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v3
46+
- name: Set up JDK 11
47+
uses: actions/setup-java@v3
48+
with:
49+
java-version: '11'
50+
distribution: 'temurin'
51+
cache: 'sbt'
52+
- name: Run Integration Tests
53+
run: sbt IntegrationTest/test
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish Artifacts
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
7+
permissions:
8+
packages: write
9+
10+
jobs:
11+
publish-artifacts:
12+
name: Publish Artifacts
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Set up JDK 11
17+
uses: actions/setup-java@v3
18+
with:
19+
java-version: '11'
20+
distribution: 'temurin'
21+
cache: 'sbt'
22+
- name: Publish Jars
23+
run: sbt publish
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish-docs.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish Documents
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
publish-docs:
12+
name: Publish Documents
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-python@v3
17+
- name: Install Sphinx Dependencies
18+
run: pip install sphinx sphinx_rtd_theme recommonmark sphinx-autobuild myst-parser
19+
- name: Generate HTML Files
20+
run: sphinx-build -b html docs/source/ docs/build/html
21+
- name: Deploy HTML Files
22+
uses: peaceiris/actions-gh-pages@v3
23+
with:
24+
publish_branch: github-pages
25+
github_token: ${{ secrets.GITHUB_TOKEN }}
26+
publish_dir: docs/build/html
27+
force_orphan: true

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.bloop
2+
.metals
3+
.venv
4+
.vscode
5+
6+
project
7+
target
8+
9+
docs/build

.scalafmt.conf

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
version = "3.0.2"
2+
maxColumn = 120
3+
importSelectors = singleLine
4+
5+
docstrings {
6+
style = Asterisk
7+
oneline = unfold
8+
}
9+
10+
rewrite {
11+
rules = [
12+
RedundantParens,
13+
SortImports,
14+
SortModifiers,
15+
PreferCurlyFors
16+
]
17+
}
18+
19+
assumeStandardLibraryStripMargin = true
20+
21+
align {
22+
stripMargin = true
23+
preset = some
24+
}
25+
26+
indent {
27+
extendSite = 4
28+
withSiteRelativeToExtends = 0
29+
}
30+
31+
newlines {
32+
beforeMultiline = unfold
33+
afterCurlyLambdaParams = squash
34+
implicitParamListModifierPrefer = before
35+
alwaysBeforeMultilineDef = true
36+
topLevelStatements = [before, after]
37+
topLevelStatementBlankLines = [
38+
{
39+
blanks = 1
40+
}
41+
]
42+
}
43+
44+
runner.dialect = scala3

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Sample README document
2+
3+
Replace `<repo_name>` with your repository name in below 2 files:
4+
* docs/source/conf.py
5+
* build.sbt

build.sbt

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
ThisBuild / scalaVersion := "3.3.0"
2+
3+
lazy val scalacOptions = Seq("-Xmax-inlines", "50")
4+
5+
// ----- VARIABLES ----- //
6+
7+
val organizationName = "com.clairvoyant"
8+
val projectName = "<repo_name>"
9+
val releaseVersion = "1.0.0"
10+
11+
val scalaTestVersion = "3.2.15"
12+
val scalaXmlVersion = "2.1.0"
13+
val scalaParserCombinatorsVersion = "2.2.0"
14+
15+
// ----- TOOL DEPENDENCIES ----- //
16+
17+
val scalaTestDependencies = Seq("org.scalatest" %% "scalatest" % scalaTestVersion)
18+
19+
val scalaXmlDependencies = Seq("org.scala-lang.modules" %% "scala-xml" % scalaXmlVersion)
20+
21+
val scalaParserCombinatorsDependencies = Seq(
22+
"org.scala-lang.modules" %% "scala-parser-combinators" % scalaParserCombinatorsVersion
23+
)
24+
25+
// ----- MODULE DEPENDENCIES ----- //
26+
27+
val rootDependencies =
28+
scalaTestDependencies.map(_ % "it,test") ++
29+
scalaXmlDependencies ++
30+
scalaParserCombinatorsDependencies
31+
32+
// ----- SETTINGS ----- //
33+
34+
val rootSettings =
35+
Seq(
36+
organization := organizationName,
37+
version := releaseVersion,
38+
Keys.scalacOptions ++= scalacOptions,
39+
libraryDependencies ++= rootDependencies
40+
) ++ Defaults.itSettings
41+
42+
// ----- PROJECTS ----- //
43+
44+
lazy val root = (project in file("."))
45+
.configs(IntegrationTest)
46+
.settings(rootSettings)
47+
48+
// ----- PUBLISH TO GITHUB PACKAGES ----- //
49+
50+
ThisBuild / publishTo := Some("Github Repo" at s"https://maven.pkg.github.com/teamclairvoyant/$projectName/")
51+
52+
ThisBuild / credentials += Credentials(
53+
"GitHub Package Registry",
54+
"maven.pkg.github.com",
55+
"teamclairvoyant",
56+
System.getenv("GITHUB_TOKEN")
57+
)

docs/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Steps to install [sphinx](https://www.sphinx-doc.org/en/master/) and create html files for docs
2+
3+
* Go to the terminal and navigate to the root directory
4+
* Run the below commands:
5+
```text
6+
python -m venv .venv
7+
source .venv/bin/activate
8+
python -m pip install --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org -r docs/requirements.txt
9+
sphinx-build -b html docs/source/ docs/build/html
10+
```
11+
* The `build` folder should be created inside `docs` folder.
12+
* Open `index.html` file in the browser present inside the `build/html` folder.

docs/requirements.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sphinx
2+
sphinx-rtd-theme==1.0.0
3+
recommonmark==0.7.1
4+
sphinx-autobuild==2021.3.14
5+
myst-parser==0.15.2

docs/source/conf.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
project = '<repo_name>'
2+
release = '1.0.0'
3+
4+
extensions = ['myst_parser']
5+
6+
html_theme = 'sphinx_rtd_theme'
7+
8+
html_theme_options = {
9+
'collapse_navigation': False,
10+
'sticky_navigation': False,
11+
'prev_next_buttons_location': 'both'
12+
}
13+
14+
source_suffix = {
15+
'.rst': 'restructuredtext',
16+
'.txt': 'restructuredtext',
17+
'.md': 'markdown',
18+
}
19+
20+
master_doc = 'index'
21+
22+
pygments_style = 'sphinx'
23+
24+
html_sidebars = {
25+
'**': [
26+
'about.html',
27+
'navigation.html',
28+
'relations.html',
29+
'searchbox.html',
30+
'donate.html',
31+
]
32+
}
33+
34+
highlight_language = 'scala'
35+
36+
from recommonmark.transform import AutoStructify
37+
38+
def setup(app):
39+
app.add_config_value('recommonmark_config', {
40+
'auto_toc_tree_section': 'Contents',
41+
'enable_auto_doc_ref': False
42+
}, True)
43+
app.add_transform(AutoStructify)

docs/source/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Starting point of documentation

project/build.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.9.0

project/plugins.sbt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.clairvoyant
2+
3+
import org.scalatest.flatspec.AnyFlatSpec
4+
import org.scalatest.matchers.should.Matchers
5+
6+
class MyScalaApplicationIntegrationTest extends AnyFlatSpec with Matchers {
7+
8+
"MyScalaApplication main()" should "run successfully" in {
9+
MyScalaApplication.main(Array(""))
10+
}
11+
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.clairvoyant
2+
3+
object MyScalaApplication extends App {
4+
val calculator = new MyCalculator
5+
6+
print(calculator.add(10, 5))
7+
}
8+
9+
class MyCalculator {
10+
def add(a: Int, b: Int): Int = a + b
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.clairvoyant
2+
3+
import org.scalatest.flatspec.AnyFlatSpec
4+
import org.scalatest.matchers.should.Matchers
5+
6+
class MyScalaApplicationSpec extends AnyFlatSpec with Matchers {
7+
8+
"add()" should "add two numbers correctly" in {
9+
val calculator = new MyCalculator
10+
11+
calculator.add(10, 5) shouldBe 15
12+
}
13+
14+
}

0 commit comments

Comments
 (0)