CSGE602022 - Platform-Based Programming (Pemrograman Berbasis Platform) @ Faculty of Computer Science Universitas Indonesia, Odd Semester 2021/2022
Welcome to the code repository. This repository hosts weekly tutorial codes and other, such as course-related code snippets.
- Weekly Exercises
- Quickstart Guide
- Initial Setup
- Doing the Tutorial
- Pulling Updates From Upstream
- Show Code Coverage in Gitlab
- Grading Scheme & Demonstration
After you work at Lab 1, make sure to link this repository to your Lab 1 Repository :
- Add this repository link to your remote list as
upstream
(git remote add upstream https://gitlab.com/PBP-2021/pbp-lab
) - Pull the latest update to check whether new tutorials have been updated (
git pull upstream master
) - Fix any merge conflict(s) that might arise (hopefully none)
- Always choose latest commit from
upstream
when fixing merge conflict(s)
- Always choose latest commit from
- Do not forget to commit your merged
master
branch and push it to your ownmaster
branch at GitLab repository - Use Git command:git push origin master
Working on a tutorial problem set (This instructions applied for 3rd tutorials and so on):
- Pull any updates from
upstream
- Create new apps on Django Project based on your tutorials
python manage.py startapp lab_n
where n is turoial number. E.g. lab_2 - Do the exercises as instructed in README.md file (click this to see this week Tutorials README.md)
- Commit your work frequently
- Write good commit message(s)
- If your work is ready for grading:
git push origin master
If you want to know the detailed explanation about each instructions above, please read the following sections.
If you previously haven't worked on Lab 1 Tutorial
- then Create a fork of this repository to your GitLab account, which will create a copy of this repository under your own account.
- Open the forked repository page at
https://gitlab.com/<YOURNAME>/pbp-lab
where<YOURNAME>
is your GitLab username. - Set the clone URL to HTTPS and copy the URL into clipboard.
- Clone the repository into your local machine. Use Git command:
git clone https://gitlab.com/<YOURNAME>/pbp-lab.git <PATH>
where<PATH>
is a path to a directory in your local machine. - Go to the directory where the cloned repository is located in your local machine.
- Add new remote called upstream that points to the original
GitLab repository. Use Git command:
git remote add upstream https://gitlab.com/PBP-2021/pbp-lab
- Tell your TA about your GitLab username and URL to your tutorial repository so s/he can grade it later.
- Ensure that your repository page has visibility level set to Internal or Public. Check it in Edit Project menu at your repository page.
If you did Lab 1 Tutorial
- Add new remote called upstream that points to the original
GitLab repository. Use Git command:
git remote add upstream git remote add upstream https://gitlab.com/PBP-2021/pbp-lab
- Tell your TA about your GitLab username and URL to your tutorial repository so s/he can grade it later.
- Ensure that your repository page has visibility level set to Internal or Public. Check it in Edit Project menu at your repository page.
- Suppose that you want to work on Lab 1 problem set. Go to the directory that containing Lab 1 README.md.
- To ensure your work regarding Lab 1 problem is isolated from
your other attempts on other problems, create a new apps
specifically for working on Lab 1 problem. Use Python command:
python manage.py startapp lab_1
- Read the README file carefully because It contains set of tasks and instructions that you can work on.
- Do the tutorial.
- Use
git add
orgit rm
to stage/unstage files that you want to save into Git later. - Once you want to save your progress, commit your work to Git. Use
Git command:
git commit
A text editor will appear where you should write a commit message. Please try to follow the guidelines written in this guide on how to write a good commit message. - Repeat steps 4 - 6 until you finish the tutorial.
- Once you are ready to submit your work or you want to save it to
your repository on GitLab, do a Git push. The Git command:
git push origin master
If there are any updates from upstream, you can get the latest commits
and integrate it into your fork by using the following Git command:
git pull upstream master
Merge conflicts may arise since the repository is updated weekly and
may have overlapping changes with the master
branch in your own
forked repository. If merge conflict happens, please always use latest
commit from upstream
. Once you have resolved any merge conflicts and all commits from
upstream are merged succesfully to your own master
branch, do not
forget to push it back to your own GitLab repository. Use Git command:
git push origin master
- Go to CI/CD Settings (
Settings -> CI/CD
) - Go to section Coverage Settings (
General pipelines -> Test coverage parsing
) - Write this Regex (Regular Expression) in textbox
Test Coverage Parsing
TOTAL\s+\d+\s+\d+\s+(\d+)%
- Save the changes.
- To add coverage badge to gitlab like:
- On top of the project:
- Go to General Settings (
Settings -> General
) - Go to section Badges
- Create a new badge with
Badge image URL
for pipeline:https://gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg
- and for the coverage badge:
https://gitlab.com/%{project_path}/badges/%{default_branch}/coverage.svg
- Go to General Settings (
- On the
README.md
:- Add 2 new lines to your
README.md
:[![Pipeline](https://gitlab.com/YOUR_GITLAB_USERNAME/YOUR_REPOSITORY_NAME/badges/master/pipeline.svg)](https://gitlab.com/YOUR_GITLAB_USERNAME/YOUR_REPOSITORY_NAME/pipelines) [![Coverage](https://gitlab.com/YOUR_GITLAB_USERNAME/YOUR_REPOSITORY_NAME/badges/master/coverage.svg)](https://gitlab.com/YOUR_GITLAB_USERNAME/YOUR_REPOSITORY_NAME/pipelines)
- Change
YOUR_GITLAB_USERNAME
andYOUR_REPOSITORY_NAME
to match your repository. example for this repository:[![Pipeline](https://gitlab.com/PBP-2021/pbp-lab/badges/master/pipeline.svg)](https://gitlab.com/PBP-2021/pbp-lab/pipelines) [![Coverage](https://gitlab.com/PBP-2021/pbp-lab/badges/master/coverage.svg)](https://gitlab.com/PBP-2021/pbp-lab/pipelines)
- Add 2 new lines to your
- On top of the project:
- Run a new pipeline for them to get updated. You can push a new commit or retry your last pipeline.
- Get a copy of Repo PBP from one of your working station (PC Lab, laptop or homedesktop). in one of your working station (PC Lab, laptop or homedesktop) by executing the clone command.
It is possible to download and extract it to a different directory
-
Create a new project on GitLab where you will store this exercise.
-
Go to the directory where you extracted the Repo PBP and initialize the directory into a Git repository.
-
Add new Git remote that link the local Repo PBP repository to your new GitLab repository.
At this stage, you are now ready to continue the tutorial. To save your progress,
please add any new/modified file(s) and folder(s) to local Git repository and
save it as one or more commits. Once you are done or want to ensure your progress
is stored on GitLab, use git push
to push your commits.
Now please proceed to the instructions as follows.
-
Create a virtual environment for this tutorial by using this command:
python -m venv env
Make sure that you executed the command in the root path of the repository.
-
Activate your virtual environment and install required packages. Note that the command for activating virtual environment is different on Windows and Unix-based OS.
Windows: ```bash env\Scripts\activate.bat pip install -r requirements.txt ``` Linux & Mac OS: ```bash source env/bin/activate pip install -r requirements.txt ```
-
Use your favourite editor to edit the code (Vim, VS Code, Atom) or use IDE (PyCharm).
-
Let's try running the Web locally in your machine. Run it by typing:
python manage.py runserver 8000
Ensure the current active directory in your shell/command-prompt is in the folder containing
manage.py
before executing the command above -
Access your local Web server by using your favorite Web browser. Put the address into your browser:
http://localhost:8000
-
See your work is shown in Web page rendered by browser.
-
When you are done with your tutorial or you want to switch to another Python project, do not forget to deactivate your virtual environment. You can do so by executing:
```bash deactivate ```
Weekly tutorials contribute 20% to the final grade of this course. For each exercises, student can obtain grade ranging from A (4) to E (0). The grading scheme is as follows:
- A if student completed all checklists
- B if student completed 80% of checklist
- C if student completed at least half of the checklist
- D if student completed 30% of checklist
- E if student skipped the tutorial by doing nothing, e.g. no signs of work to the tutorial in the repository
All students required to demonstrate their work to teaching assistant. This demonstration mechanism applies for both students in Regular and International classes:
- Demonstrations should be done no later than the end of the lab session week. The time allocation for the demonstration can be adjusted to the availability of the Teaching Assistants. As long as the demonstration is still done before your lab session, students have the chance to achieve maximum score for the tutorial.
- If the demonstration is done after your lab session, you have to demonstrate your work to your lecturer and your score won't reach maximum point eventhough you do all checklists
- Git Tutorials & Training by Atlassian
- Try Git in your Web browser
- Pro Git e-Book by Scott Chacon & Ben Straub
- Graph theory and its application in Git
- How to Write a Git Commit Message
This document is based on Exercise 0: Introduction to Git written by Advanced Programming 2017 Teaching Team (@addianto, @muhammad.ardhan, @fbenarto, et al.). The section about branching and handling merge conflicts are omitted in this document to make sure the Git tutorial can be completed by students during Web Design & Programming lab session.