Skip to content

Commit 64e17a3

Browse files
authored
Merge pull request #16 from kraker/linting
Feature - Linting, syntax, and validation
2 parents 0640905 + 826e814 commit 64e17a3

25 files changed

+1770
-33
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,38 @@
1-
name: ci
1+
---
2+
# .github/workflows/ci.yml
3+
4+
name: ci
25
on:
36
push:
47
branches:
5-
- master
8+
# - dev
9+
- master
610
- main
711
permissions:
812
contents: write
13+
914
jobs:
15+
# Linting, syntax, and other checks
16+
validate:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: 3.x
23+
- run: python3 -m pip install -r requirements-dev.txt
24+
- run: pre-commit install
25+
- run: pre-commit install-hooks
26+
- run: pre-commit run --all-files
27+
28+
# TODO: Deploy to dev site for testing?
29+
30+
# Build and deploy the site
1031
deploy:
32+
# Only deploy from master or main branches
33+
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
34+
# Only build and deploy if validate succeeds
35+
needs: validate
1136
runs-on: ubuntu-latest
1237
steps:
1338
- uses: actions/checkout@v4
@@ -18,12 +43,12 @@ jobs:
1843
- uses: actions/setup-python@v5
1944
with:
2045
python-version: 3.x
21-
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
46+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
2247
- uses: actions/cache@v4
2348
with:
2449
key: mkdocs-material-${{ env.cache_id }}
2550
path: .cache
2651
restore-keys: |
2752
mkdocs-material-
28-
- run: pip install mkdocs-material
29-
- run: mkdocs gh-deploy --force
53+
- run: pip install mkdocs-material
54+
- run: mkdocs gh-deploy --force

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1+
# .gitignore
2+
13
/html/
4+
5+
# python
6+
.env/
7+
8+
# nodejs
9+
node_modules/

.markdownlintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# .markdownlintignore
2+
3+
# TODO: Lint these files
4+
.github/
5+
docs/
6+
README.md

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
# .pre-commit-config.yaml
3+
4+
# See https://pre-commit.com for more information
5+
# See https://pre-commit.com/hooks.html for more hooks
6+
7+
repos:
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v5.0.0
10+
hooks:
11+
- id: trailing-whitespace
12+
- id: end-of-file-fixer
13+
# - id: check-yaml
14+
- id: check-added-large-files
15+
# https://yamllint.readthedocs.io/en/stable/integration.html#integration-with-pre-commit
16+
- repo: https://github.com/adrienverge/yamllint.git
17+
rev: v1.29.0
18+
hooks:
19+
- id: yamllint
20+
# https://github.com/igorshubovych/markdownlint-cli/blob/master/README.md#use-with-pre-commit
21+
- repo: https://github.com/igorshubovych/markdownlint-cli
22+
rev: v0.45.0
23+
hooks:
24+
- id: markdownlint
25+
# https://github.com/shellcheck-py/shellcheck-py/blob/main/README.md#as-a-pre-commit-hook
26+
- repo: https://github.com/shellcheck-py/shellcheck-py
27+
rev: v0.10.0.1
28+
hooks:
29+
- id: shellcheck

.yamllint

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
# .yamllint
3+
4+
extends: default
5+
6+
ignore:
7+
- .env/
8+
- node_modules/
9+
# TODO: Lint these files
10+
- .github/
11+
- mkdocs.yml

CONTRIBUTING.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Contributing #
2+
3+
This guide is a _work in progress_, PR's welcome!
4+
5+
TODO
6+
7+
## Issues ##
8+
9+
TODO
10+
11+
## Pull-requests ##
12+
13+
TODO
14+
15+
## Development environment ##
16+
17+
Setting up a local development environment in Linux. Pull-requests welcome for
18+
MacOS support. (Although, this _is_ the "Linux Upskill Challenge", why not Linux?)
19+
20+
### Python environment ###
21+
22+
Setting up a local python virtual environment is recommended.
23+
24+
```bash
25+
python3 -m venv .env
26+
```
27+
28+
Install python development environment dependencies.
29+
30+
```bash
31+
python3 -m pip install -r requirements-dev.txt
32+
```
33+
34+
Activate the python environment:
35+
36+
```bash
37+
source .env/bin/activate
38+
```
39+
40+
### NodeJS ###
41+
42+
The markdown linter that's used by this project is an npm package. Install
43+
markdown lint dependencies from the `package.json` file.
44+
45+
```bash
46+
npm install
47+
```
48+
49+
## Linting ##
50+
51+
Linters:
52+
53+
* [yamllint](https://yamllint.readthedocs.io/en/stable/index.html)
54+
* [markdownlint](https://github.com/DavidAnson/markdownlint)
55+
* [ShellCheck](https://github.com/koalaman/shellcheck)
56+
* Via [shellcheck-py](https://github.com/shellcheck-py/shellcheck-py). It's
57+
easier to manage this project dependency as a pip-installable package. Also,
58+
pre-commit uses shellcheck-py because the native ShellCheck pre-commit hook
59+
has an annoying Docker dependency.
60+
61+
### Pre-commit ###
62+
63+
* [pre-commit](https://pre-commit.com/)
64+
65+
If you setup your python development environment by installing pip packages
66+
from `requirements-dev.txt` earlier then `pre-commit` should already be
67+
installed in your python environment.
68+
69+
Pre-commit runs linting, syntax, and other checks via git hook scripts that
70+
run before code is committed.
71+
72+
Install pre-commit and the hook scripts defined in `.pre-commit-config.yaml`:
73+
74+
```bash
75+
pre-commit install && pre-commit install-hooks
76+
```
77+
78+
Pre-commit will now run prior to committing any code with git.
79+
80+
To manually run the hook scripts and lint the repo:
81+
82+
```bash
83+
pre-commit
84+
# or run for all files
85+
pre-commit run --all-files
86+
```
87+
88+
## Build ##
89+
90+
This project uses the [MkDocs](https://www.mkdocs.org/) Python static site
91+
generator geared towards building project docs. It uses the
92+
[mkdocs-material](https://github.com/squidfunk/mkdocs-material) theme.
93+
94+
If you setup your Python environment above, then the mkdocs and mkdocs-material
95+
packages should already be installed.
96+
97+
A local instance of the site can be built and served via localhost by running...
98+
99+
```bash
100+
mkdocs server
101+
```
102+
103+
...from the project root directory.
104+
105+
Served from localhost: [LUC @localhost](http://127.0.0.1:8000)
106+
107+
### GitHub Actions workflows ###
108+
109+
Stages:
110+
111+
* Validate
112+
* Build & Deploy
113+
114+
TODO: Flesh out this section.

docs/00-Azure-Free-Tier.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ You will need to also provide your VISA or other credit card information.
2424
- Click 'Review + Create'
2525
- Azure will generate and download the private key file to SSH onto the box -
2626
- (Windows) double-click this to open on Windows and it will be added to your cert store on the machine
27-
- (Mac OS X and Linux) run the command 'sudo ssh-add -K /link-to-downloaded-file'
27+
- (Mac OS X and Linux) run the command 'sudo ssh-add -K /link-to-downloaded-file'
2828
- Note: if the above command doesn't work for you then try running without sudo. If you get any error related to permissions then try running 'chmod 400 filename' first.
2929
- Connect to the machine using `ssh azureuser@PUBLICIP`
3030

docs/00-Local-Server.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ Use **arrow keys** and the **enter key** to select options. When you're ok with
7373
* **Profile Setup:** Enter your name, your server’s name, your username and password. This user will be your `administrator` user in the system (or `sudo`), so don't forget this password.
7474
* **Update to Ubuntu Pro:** No. Skip for now.
7575
* **SSH setup:** Select on Install OpenSSH server because that’s how you will connect to your server later.
76-
* **Featured Server Snaps:** None of these packages are important now, just select DONE.
76+
* **Featured Server Snaps:** None of these packages are important now, just select DONE.
7777
* **Installing System:** Now you have to wait for a few minutes for your system to install. You can "cheat" and speed up the install by skipping the downloading of updates, select **Cancel update and Reboot** when it appears at the bottom of the page, a few moments later. You can complete the updates after the first boot. After the installation is complete the system will reboot automatically.
7878

7979
## Logging in for the first time
8080

81-
After the first reboot, it will show a black screen asking for the `login`. That's when you use that username and password you created during the install.
81+
After the first reboot, it will show a black screen asking for the `login`. That's when you use that username and password you created during the install.
8282

8383
Note: the password will not show up, not even `***`, just trust that is taking it in.
8484

docs/00-VPS-big.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Sign-up is fairly simple - just provide your email address and a password of you
1515

1616
### Comparison
1717

18-
| Provider | Instance Type | vCPU | Memory | Storage | Price* | Trial Credits |
19-
| ------------- | ----------------------- | ---- | ------ | --------- | ------ | -------------- |
18+
| Provider | Instance Type | vCPU | Memory | Storage | Price* | Trial Credits |
19+
| ------------- | ----------------------- | ---- | ------ | --------- | ------ | -------------- |
2020
| [AWS](https://aws.amazon.com/free/) | t2.micro | 1 | 1 GB | 8 GB SSD | $18.27 | Free Tier for 1 year |
2121
| [Azure](https://azure.microsoft.com/free/) | B1 | 1 | 1 GB | 30 GB SSD | $12.26 | $200 / 30 days + Free Tier for 1 year |
2222
| [GCP](https://cloud.google.com/free/docs/free-cloud-features) | e2-micro | 1 | 1 GB | 10 GB SSD | $ 7.11 | $300 / 90 days |
@@ -33,7 +33,7 @@ On a side note, avoid IBM Cloud as much as you can. They do not offer good deals
3333
* Google Cloud for Students at [https://cloud.google.com/edu/students](https://cloud.google.com/edu/students)
3434
* Oracle Academy Cloud Program at [https://academy.oracle.com/en/solutions-cloud-program.html](https://academy.oracle.com/en/solutions-cloud-program.html)
3535

36-
## Create a Virtual Machine
36+
## Create a Virtual Machine
3737

3838
The process is basically the same for all these VPS, but here are some step-by-steps:
3939

docs/00-VPS-small.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ Refer to [Day 0 - Get Your Own Server](https://linuxupskillchallenge.org/00) to
1414
Sign-up is immediate - just provide your email address and a password of your choosing and you're in! To be able to create a VM, however, you may need to provide your credit card information (or other information for billing) in the account section.
1515

1616
### Comparison
17-
| Provider | Instance Type | vCPU | Memory | Storage | Price | Trial Credits |
18-
| ------------- | ----------------------- | ---- | ------ | --------- | ----- | -------------- |
19-
| [Digital Ocean](https://m.do.co/c/0543704a0b92) | Basic Plan | 1 | 1 GB | 25 GB SSD | $6.00 | $200 / 60 days |
20-
| [Linode](https://www.linode.com/lp/refer/?r=5f3727944be972fe99747977e0a25fc21390c5d0) | Nanode 1GB | 1 | 1 GB | 25 GB SSD | $5.00 | $100 / 60 days |
17+
| Provider | Instance Type | vCPU | Memory | Storage | Price | Trial Credits |
18+
| ------------- | ----------------------- | ---- | ------ | --------- | ----- | -------------- |
19+
| [Digital Ocean](https://m.do.co/c/0543704a0b92) | Basic Plan | 1 | 1 GB | 25 GB SSD | $6.00 | $200 / 60 days |
20+
| [Linode](https://www.linode.com/lp/refer/?r=5f3727944be972fe99747977e0a25fc21390c5d0) | Nanode 1GB | 1 | 1 GB | 25 GB SSD | $5.00 | $100 / 60 days |
2121
| [Vultr](https://www.vultr.com/vultr-vs-linode/?promo=LINODE150) | Cloud Compute - Regular | 1 | 1 GB | 25 GB SSD | $5.00 | $250 / 30 days |
2222

2323
For more details:
@@ -26,7 +26,7 @@ For more details:
2626
* [Get started with Linode](https://www.linode.com/docs/products/platform/get-started/)
2727
* [Get started with Vultr](https://www.vultr.com/resources/faq/)
2828

29-
## Create a Virtual Machine
29+
## Create a Virtual Machine
3030

3131
The process is basically the same for all these VPS, but here some step-by-steps:
3232

0 commit comments

Comments
 (0)