Module 03 · Final Project and Assessment最终项目与评估
Part 1 - GitHub UI第 1 部分 - GitHub 界面
Estimated Time: 30 minutes
预计时间:30 分钟
Scenario 场景
You recently got hired as a developer in a micro-finance startup with a mission to empower and provide opportunities for low income individuals. The core team currently uses Subversion (SVN) for managing code. They want to slowly move their code to Git. You are asked to host their sample code to calculate simple interest on GitHub in a new repository as the first step in this journey. You will not only host the script, but also follow best practices introduced in this course and create supporting documents for the open source project including a code of conduct, and contribution guidelines. Additionally, the repository should be available to the community under the Apache License 2.0.
您最近被一家微型金融初创公司聘为开发者,该公司的使命是赋能和为低收入个体提供机会。核心团队目前使用 Subversion(SVN)来管理代码。他们希望逐步将代码迁移到 Git。您被要求在 GitHub 上创建一个新的仓库来托管计算简单利息的示例代码,这是这一旅程的第一步。您不仅要托管脚本,还要遵循本课程中介绍的最佳实践,并为开源项目创建支持性文档,包括行为准则和贡献指南。此外,该仓库应在 Apache License 2.0 许可下对社区开放。
Objectives 目标
After completing this lab, you would have demonstrated that you can:
完成这个实验室后,你将证明你能够:
- Create a new repository in your GitHub account.
在您的 GitHub 账户中创建一个新的仓库。 - Select the appropriate license for your project.
选择适合您项目的许可证。 - Create a README.md file that explains the purpose of the project.
创建一个 README.md 文件,解释项目的目的。 - Create a Code of Conduct markdown that explains how you want the community to behave and interact with each other.
创建一份行为准则 Markdown 文档,解释您希望社区成员如何相互行为和互动。 - Create a Contribution Guidelines markdown that tells the community how to contribute.
创建一份贡献指南的 Markdown 文档,告诉社区如何进行贡献。 - Commit the new files to the repository.
将新文件提交到仓库。
Note: Throughout this lab, you will be prompted to copy and paste URLs into an editor and save it on your own device. These URLs will be uploaded for peer review in the Final Submission section of the course. You can use any editor app to keep note of your URLs.
注意:在整个实验过程中,您将被提示将 URL 复制粘贴到编辑器中,并保存在您的设备上。这些 URL 将在课程的最终提交部分上传以供同行评审。您可以使用任何编辑器应用来记录您的 URL。
Task 1: Create a GitHub repository 任务 1:创建 GitHub 仓库
- Create a new GitHub repository called "github-final-project" and make sure that it is public.
创建一个名为“github-final-project”的新 GitHub 仓库,并确保它是公开的。 - Select the Add a README file and Choose a license check boxes. Pick
Apache 2.0 Licensefrom the drop down.
选择“添加 README 文件”和“选择许可证”复选框。从下拉菜单中选择Apache 2.0 License。 - Click Create repository. Your repository is created and includes the README and LICENSE files. Now, you are ready to update your repository files to include useful information for your community.
点击创建仓库。您的仓库已创建,包括 README 和 LICENSE 文件。现在,您可以更新仓库文件,为您的社区添加有用信息。 - Save the URL of the repository in a Notepad to submit later for peer review.
保存仓库的 URL 到记事本中,稍后提交给同行评审。
Task 2: Add a license file 任务 2:添加许可证文件
- As part of Task 1, you picked a licence when creating the repository.
作为任务 1 的一部分,你在创建仓库时选择了一个许可证。 - Open the LICENSE.md file and check that its content are pointing to
Apache License 2.0.
打开 LICENSE.md 文件并检查其内容是否指向Apache License 2.0。
Task 3: Update the README file 任务 3:更新 README 文件
- Add the following information to the file:
请将以下信息添加到文件中:
A calculator that calculates simple interest given principal, annual rate of interest and time period in years.
Input:
p, principal amount
t, time period in years
r, annual rate of interest
Output
simple interest = p*t*r
Optional - You can continue to update the README file as you develop your project. You can find some ideas for useful README content from the following resources:
可选 - 您可以在开发项目时继续更新 README 文件。您可以从以下资源中找到一些有用的 README 内容想法:
Task 4: Add a code of conduct 任务 4:添加行为准则
A code of conduct helps set the ground rules for the behavior of your project's participants. It defines standards for how to engage in a community.
行为准则有助于为项目参与者的行为设定基本规则。它定义了如何在社区中参与的标准。
GitHub provides templates for common codes of conduct to help you quickly add one to your project. To add a code of conduct to your project, complete the following steps:
GitHub 提供了常见行为准则的模板,以帮助您快速将其添加到您的项目中。要将行为准则添加到您的项目中,请完成以下步骤:
- Add a new file named
CODE_OF_CONDUCT.mdto the root folder of the repository with the "Contributor Covenant" template.
将名为“CODE_OF_CONDUCT.md”的新文件添加到仓库根目录中,包含“贡献者公约”模板。 - Go to your repositories homepage and check if the file has been created.
前往您的仓库主页检查文件是否已创建。
Task 5: Add contribution guidelines 任务 5:添加贡献指南
The contribution guidelines tell project participants how to contribute to the project. To add contributions guidelines, complete the following steps:
贡献指南告知项目参与者如何为项目做出贡献。要添加贡献指南,请完成以下步骤:
- Create a new file named
CONTRIBUTING.mdin the root directory of the repository with the following information:
创建一个名为CONTRIBUTING.md的新文件,存放在仓库的根目录下,包含以下信息:
All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome.
- Optionally, you can review the following guides for examples of contribution guidelines and update this file.
可选地,您可以查看以下指南以获取贡献指南的示例并更新此文件。 - Commit the file into the main branch and check if it is listed on the homepage of the repository.
将文件提交到主分支并检查它是否列在仓库的主页上。
Task 6: Host the script file 任务 6:托管脚本文件
- Create a new file named
simple-interest.shin the root directory of the repository.
在仓库根目录下创建一个名为simple-interest.sh的新文件。 - Add the following code in the new file:
在新的文件中添加以下代码:
#!/bin/bash
# This script calculates simple interest given principal,
# annual rate of interest and time period in years.
# Do not use this in production. Sample purpose only.
# Author: Upkar Lidder (IBM)
# Additional Authors:
# <your GitHub username>
# Input:
# p, principal amount
# t, time period in years
# r, annual rate of interest
# Output:
# simple interest = p*t*r
echo "Enter the principal:"
read p
echo "Enter rate of interest per year:"
read r
echo "Enter time period in years:"
read t
s=`expr $p \* $t \* $r / 100`
echo "The simple interest is: "
echo $s
- Commit the file into the main branch.
将文件提交到主分支。
Checklist 清单
Save your repository URL safely for use in your submission later in this course.
保存您的仓库 URL,以便在课程后期提交时使用。