Skip to content

govUA/scala-course-spring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Functional Programing Course at KSE

Scala Course Spring

Documentation and Resources

External Courses

Telegram community

Course format

Each homework assignment corresponds to a specific unit in the course, labeled as unit1, unit2, and so on.

For each unit, there are two main components: topic and challange, covering both main and test.

In the topic section, relevant material is explained, and template tests are provided. The challange section involves implementing or improving code or approaches similar to those covered in the topic. Tests are a required and integral part of the assignment contract unless explicitly stated otherwise.

Requirements for Submitting Homework for Review

Failure to comply with any of the following rules will result in the homework not being reviewed:

  • Both main and test code must compile successfully.
  • Tests must be implemented unless explicitly stated otherwise.
  • All tests must pass.
  • The code must adhere to formatting guidelines.

Students may submit incomplete homework to verify assumptions, but any incompleteness must be explicitly stated in the submission.

Code style

The project uses scalafmt as the code formatter for Scala. All code must be formatted using scalafmt after each commit.

Prerequisites

How to start

  1. Install Git on your local machine if needed.
  2. Install Sbt on your local machine if needed.
  3. Create a GitHub account (if you don’t already have one).
  4. Set up a private GitHub repository.
  5. Clone the repository locally (do not fork it).
  6. Push the local repository to your private GitHub repository.
  7. Create a new branch for each challenge assignment.

Create GitHub account

Open https://github.com/ and follow the sign-up procedure. It's better to choose a professional-like name, usually [First][Last] name (my personal GitHub account is https://github.com/IgorWolkov). Follow the guide to setup GitHub account in Intellij Idea

Create a new repository on GitHub

To create a new repository on GitHub follow the guide.

  • It is required that the repository must be private.
  • It is required that the repository must be named as scala-course-spring as the original one.

Clone the course repository

To clone a repository follow the guide.

Please do not fork the repository.

Create a GitHub account

Visit https://github.com/ and follow the sign-up process. Choose a professional username, typically in the format [First][Last] name (e.g., my personal GitHub account is https://github.com/IgorWolkov). Follow this guide to set up your GitHub account in IntelliJ IDEA.

Create a new repository on GitHub

To create a new repository on GitHub, follow this guide.

Clone the Course Repository

To clone the repository, follow this guide.

Important: Please do not fork the repository.

The course repository is here. You can either use Intellij IDE or do it manually. For manually cloning create a new folder called scala-course-spring, move to the folder and run

git clone https://github.com/Functional-Programming-KSE/scala-course-spring.git

in the commandline

Verify the cloned repository

Check the remote

To check the remote repositories run the following command

git remote -v

in the commandline, the output should be

origin	https://github.com/Functional-Programming-KSE/scala-course-spring.git (fetch)
origin	https://github.com/Functional-Programming-KSE/scala-course-spring.git (push)

Check the branches

To check the branches run the following command

git branch

in the commandline, the output should be

* main

Compile the code

To check the code compiles run the following command

sbt clean compile

in the commandline.

Secure the original repository

Students not allowed to push the changes to the original course repository. To prevent accidental pushes, it is necessary to detach the original repository from your private repository. To do this, rename the origin and disable push to the original course repository.

Rename origin

To rename the origin run the following command

git remote rename origin course

in the commandline.

Run git remote -v in the commandline, the output should be

course	https://github.com/Functional-Programming-KSE/scala-course-spring.git (fetch)
course	https://github.com/Functional-Programming-KSE/scala-course-spring.git (push)

Disable pushes

To prevent pushing to the course repository replace push url by any non-existent url, i.e. DISABLED run the following command

git remote set-url --push course DISABLED

in the commandline.

Run git remote -v in the commandline, the output should be

course	https://github.com/Functional-Programming-KSE/scala-course-spring.git (fetch)
course	DISABLED (push)

Link the local repository to your private repository

To link the local repository to your private GitHub repository add new origin.

Open the newly created repository

Open your new GitHub repository web page and follow the instructions in …or push an existing repository from the command line section. There should be a list of commands:

git remote add origin <your private repository>
git branch -M main
git push -u origin main

Run each command one-by-one in the commandline.

Execute git remote -v in the commandline, the output should be

course	https://github.com/Functional-Programming-KSE/scala-course-spring.git (fetch)
course	DISABLED (push)
origin  https://github.com/<your github account>/scala-course-spring.git (fetch)
origin  https://github.com/<your github account>/scala-course-spring.git (push)

Pull Updates from the Original Course Repository

The original course repository may be updated from time to time.

To fetch updates from the original course repository run the following command

git pull course main

in the commandline.

New branch for each homework

A separate branch must be created for each homework assignment. Students are not allowed to commit any changes to the main branch, except in cases explicitly described. Students not allowed to commit any changes to main branch except the cases described explicitly.

Code compilation and verification

Compilation

Source code compilation

To compile the source code (located in main/ folder) run

sbt clean compile

in the commandline, or

clean; compile

in the sbt shell.

Test code compilation

To compile the test code (located in test/ folder) run

sbt Test / compile

in the commandline, or

Test / compile

in the sbt shell.

Test execution

To execute all tests in the project run test command.

Note: the next command fails and it is expected:

sbt test

in the commandline, or

test

in the sbt shell.

The failure occurs because the test command runs all tests in the project. Since some homework tests have not been implemented yet, this results in a failure.

Single test execution

To execute a single tests run the following command

sbt testOnly <path to the test>

in the commandline, or

testOnly <path to the test>

in the sbt shell,

For example to execute FunctionsSpecification from Unit 1 topic run the following command

sbt testOnly kse.unit1.topic.FunctionsSpecification

in the commandline, or

testOnly kse.unit1.topic.FunctionsSpecification

Specific unit tests execution

To execute the tests for a certain unit run the following command

sbt testOnly <path to the certain unit>

in the commandline, or

testOnly <path to the certain unit>

in the sbt shell, where <path to the certain unit> is

  • kse.unit1 for the Unit 1;

  • kse.unit2 for the Unit 2;

    ...

  • kse.unitN for the Unit N;

i.e. to execute tests for Unit 1 run the following command

sbt testOnly kse.unit1

in the commandline, or

testOnly kse.unit1

in the sbt shell,

Code style

Scalafmt is used to check the code formatting and re-formatting the code according to the rules described in .scalafmt.conf file in the root (scala-course-spring) folder. These rules are applied for code checking in GitHub Action builds.

Follow the guide for setting up code re-formatting via your IDE.

Checking code style

main/ location

To check whether the code in main/ is properly formatted run

sbt scalafmtCheck

in the commandline, or

scalafmtCheck

in the sbt shell.

test/ location

To check whether the code in test/ is properly formatted run

sbt "Test / scalafmtCheck"

in the commandline, or

Test / scalafmtCheck

in the sbt shell.

All locations

To check whether the code in all locations is properly formatted run

sbt scalafmtCheckAll

in the commandline, or

scalafmtCheckAll

in the sbt shell.

Fixing code style

IDE

Follow the guide for setting up code re-formatting via your IDE.

main/ location

To check whether the code in main/ is properly formatted run

sbt scalafmt

in the commandline, or

scalafmt

in the sbt shell.

test/ location

To check whether the code in test/ is properly formatted run

sbt "Test / scalafmt"

in the commandline, or

Test / scalafmt

in the sbt shell.

All locations

To check whether the code in all locations is properly formatted run

sbt scalafmtAll

in the commandline, or

scalafmtAll

in the sbt shell.

One ring command to rule them all

Compile and fix formatting

To compile the code and fix the formatting run

sbt clean compile Test/compile scalafmtAll scalafmtCheckAll

in the commandline, or

clean; compile; Test/compile; scalafmtAll; scalafmtCheckAll

in the sbt shell.

Compile, fix formatting and run tests

To compile the code, fix the formatting and run tests for a certain unit run

sbt clean compile Test/compile scalafmtAll scalafmtCheckAll testOnly <path to the certain unit>

in the commandline, or

clean; compile; Test/compile; scalafmtAll; scalafmtCheckAll; testOnly <path to the certain unit>

GitHub Actions build

To replicate the behavior of the GitHub Actions build locally, run:

sbt clean compile Test/compile scalafmtCheckAll testOnly <path to the certain unit>

in the commandline, or

sbt clean; compile; Test/compile; scalafmtCheckAll; testOnly <path to the certain unit>

in the sbt shell

Passing the homework

New branch for each homework

Students not allowed to commit any changes to main branch except the cases described explicitly.

  • It is required to have a separate branch for each homework.
  • It is required to follow the naming convention for the branches:
    • unit-1 for Unit 1

    • unit-2 for Unit 2

      ...

    • unit-n for Unit n

The name convention is used in the GitHub Actions build setup to run the only tests related to a certain unit. Violating of the conventions leads to failed builds.

Repeat it everytime

  1. Checkout main branch.
  2. Update main branch.
  3. Create or checkout a local unit-n branch.
  4. Merge main branch into the local unit-n branch.
  5. Commit all necessary changes to the local unit-n branch.
  6. Push the changes to the your private remote GitHub repository.
  7. Create a pull request.
  8. Assign reviewers

IntelliJ IDEA UI Git management

Using the IntelliJ IDEA UI to manage Git actions is easy.

About

Tasks completed for Scala assignments during the Functional Programming course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages