Skip to content

Commit

Permalink
Merge pull request #158 from nicolasfara/develop
Browse files Browse the repository at this point in the history
New release v1.0.0
  • Loading branch information
nicolasfara authored Oct 14, 2021
2 parents 6364363 + bd393bc commit 7dcfc99
Show file tree
Hide file tree
Showing 140 changed files with 12,453 additions and 2,837 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
matrix:
os: [ubuntu-latest]
scala: [3.0.1]
java: [adopt@1.8, adopt@1.11, [email protected]]
java: [[email protected], [email protected]]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand All @@ -33,7 +33,7 @@ jobs:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v10
uses: olafurpg/setup-scala@v13
with:
java-version: ${{ matrix.java }}

Expand All @@ -53,15 +53,17 @@ jobs:
run: sbt ++${{ matrix.scala }} githubWorkflowCheck

- name: Lint check with scalafmt
run: sbt ++${{ matrix.scala }} scalafmtCheck
run: sbt ++${{ matrix.scala }} scalafmtCheckAll

- name: Tests
run: sbt ++${{ matrix.scala }} 'core / test'
run: sbt ++${{ matrix.scala }} test

- name: Generate JaCoCo report
if: ${{ matrix.java }} == '[email protected]' && ${{ matrix.scala }} == '3.0.1' && github.event_name != 'pull_request'
run: sbt ++${{ matrix.scala }} 'core / jacoco'

- name: Publish coverage to codecov
if: ${{ matrix.java }} == '[email protected]' && ${{ matrix.scala }} == '3.0.1' && github.event_name != 'pull_request'
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down Expand Up @@ -92,7 +94,7 @@ jobs:
matrix:
os: [ubuntu-latest]
scala: [3.0.1]
java: [adopt@1.8]
java: [adopt@1.11]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand All @@ -101,7 +103,7 @@ jobs:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v10
uses: olafurpg/setup-scala@v13
with:
java-version: ${{ matrix.java }}

Expand Down Expand Up @@ -134,6 +136,9 @@ jobs:
args: '-output-format=pdf -file-line-error -synctex=1 -halt-on-error -interaction=nonstopmode -shell-escape'
working_directory: doc

- name: Create FatJar for the demo
run: sbt ++${{ matrix.scala }} 'demo / assembly'

- name: Release to Sonatype
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
Expand All @@ -153,4 +158,4 @@ jobs:
core/target/scala-3.0.1/*.jar
core/target/scala-3.0.1/*.pom
demo/target/scala-3.0.1/ECScalaDemo.jar
doc/ecscala-report.pdf
doc/ecscala-report.pdf
2 changes: 1 addition & 1 deletion .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ jobs:
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
ghapi -X DELETE $REPO/actions/artifacts/$id
done
done
done
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# ECScala
General-purpose ECS Scala framework
An ECS Scala framework

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Maven Central](https://img.shields.io/maven-central/v/dev.atedeg/ecscala_3)](https://search.maven.org/artifact/dev.atedeg/ecscala_3)
[![GitHub release](https://img.shields.io/github/release/nicolasfara/ecscala.svg)](https://gitHub.com/nicolasfara/ecscala/releases/)
![example workflow](https://github.com/nicolasfara/ecscala/workflows/CI/badge.svg)
[![codecov](https://codecov.io/gh/nicolasfara/ecscala/branch/develop/graph/badge.svg?token=0XZ4XF71AY)](https://codecov.io/gh/nicolasfara/ecscala)
Expand All @@ -10,7 +11,7 @@ General-purpose ECS Scala framework
## Getting Started

```scala
libraryDependencies += "dev.atedeg" %% "ecscala" % "0.1.0"
libraryDependencies += "dev.atedeg" %% "ecscala" % "0.2.1"
```

## Usage
Expand All @@ -29,7 +30,7 @@ object AnObject extends ECScalaDSL {
Position(1, 2) &: Velocity(3, 4) &: Gravity(9.8)
}

entity1 + Position(3, 6)
entity1 += Position(3, 6)
}
```

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ecscala

import dev.atedeg.ecscala.given
import dev.atedeg.ecscala.{ &:, CNil }
import ecscala.utils.{ JmhSettings, Position, Velocity }
import org.openjdk.jmh.annotations.Benchmark

class ComponentsContainerBenchmark extends JmhSettings {

@Benchmark
def componentsContainerBenchmark: Unit = {
val view = world.getView[Position &: Velocity &: CNil]
view foreach { (entity, comps) =>
val pos = entity.getComponent[Position].get
val vel = entity.getComponent[Velocity].get
entity.setComponent(Position(pos.x + 1, pos.y + 1))
entity.setComponent(Velocity(vel.x + 1, vel.y + 1))
}
}
}
38 changes: 0 additions & 38 deletions benchmarks/src/main/scala/ecscala/MapBenchmark.scala

This file was deleted.

8 changes: 4 additions & 4 deletions benchmarks/src/main/scala/ecscala/SystemBenchmark.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ecscala

import dev.atedeg.ecscala.util.types.given
import dev.atedeg.ecscala.{ &:, CNil, System, World }
import dev.atedeg.ecscala.given
import dev.atedeg.ecscala.{ &:, CNil, IteratingSystem, World }
import ecscala.utils.{ JmhSettings, Position, Velocity }
import org.openjdk.jmh.annotations.{ Benchmark, Setup }

Expand All @@ -11,10 +11,10 @@ class SystemBenchmark extends JmhSettings {

@Setup
def init: Unit = {
world.addSystem[Position &: Velocity &: CNil]((_, comps, _) => {
world.addSystem(IteratingSystem[Position &: Velocity &: CNil]((_, comps, _) => {
val Position(x, y) &: Velocity(v1, v2) &: CNil = comps
Position(x + 1, y) &: Velocity(v1, v2)
})
}))
}

@Benchmark
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/src/main/scala/ecscala/ViewBenchmark.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ecscala

import dev.atedeg.ecscala.util.types.given
import dev.atedeg.ecscala.given
import dev.atedeg.ecscala.{ &:, CNil, Component, World }
import ecscala.utils.{ JmhSettings, Position, Velocity }
import org.openjdk.jmh.annotations.Benchmark
Expand All @@ -12,6 +12,6 @@ class ViewBenchmark extends JmhSettings {
@Benchmark
def viewIterationBenchmark: Unit = {
val view = world.getView[Position &: Velocity &: CNil]
view foreach (_.head.addComponent(Position(2, 3)))
view foreach (_.head setComponent Position(2, 3))
}
}
16 changes: 8 additions & 8 deletions benchmarks/src/main/scala/ecscala/utils/JmhSettings.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ecscala.utils

import dev.atedeg.ecscala.util.types.given
import dev.atedeg.ecscala.given
import dev.atedeg.ecscala.{ &:, CNil, System, World }
import org.openjdk.jmh.annotations.{
Benchmark,
Expand All @@ -22,22 +22,22 @@ import org.openjdk.jmh.annotations.{
import java.util.concurrent.TimeUnit

@State(Scope.Thread)
@BenchmarkMode(Array(Mode.AverageTime))
@BenchmarkMode(Array(Mode.SampleTime))
@Threads(1)
@Fork(1)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 10, timeUnit = TimeUnit.SECONDS)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = 50, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 100, time = 100, timeUnit = TimeUnit.MILLISECONDS)
class JmhSettings {

@Param(Array("1024", "2048", "4096"))
@Param(Array("1024", "2048", "4096", "10000"))
var nEntities: Int = _
val world: World = World()

@Setup
def setup: Unit = {
val entities = (0 until nEntities) map (_ => world.createEntity())
entities foreach (_.addComponent(Position(1, 2)))
entities foreach (_.addComponent(Velocity(3, 4)))
entities foreach (_ setComponent Position(1, 2))
entities foreach (_ setComponent Velocity(3, 4))
}
}
Loading

0 comments on commit 7dcfc99

Please sign in to comment.