Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint markdown files for broken links. #497

Merged
merged 4 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI Documentation Checks

on:
push:
branches:
- main
pull_request:


jobs:
lint-markdown:
name: Lint markdown
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# This is the GitHub Actions-friendly port of the linter used in the Makefile.
- uses: gaurav-nelson/[email protected]
with:
use-quiet-mode: 'yes' # errors only.
config-file: '.github/workflows/markdownlint-config.json'
13 changes: 13 additions & 0 deletions .github/workflows/markdownlint-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"ignorePatterns" : [
{
"pattern": "0005-example.md"
}
],
"replacementPatterns": [
{
"pattern": "^/",
"replacement": "{{BASEURL}}/"
}
]
}
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ __check_defined = \
infra-configure-network \
infra-format \
infra-lint \
infra-lint-markdown \
infra-lint-scripts \
infra-lint-terraform \
infra-lint-workflows \
Expand Down Expand Up @@ -136,7 +137,10 @@ infra-check-compliance-checkov: ## Run checkov compliance checks
infra-check-compliance-tfsec: ## Run tfsec compliance checks
tfsec infra

infra-lint: infra-lint-scripts infra-lint-terraform infra-lint-workflows ## Lint infra code
infra-lint: infra-lint-markdown infra-lint-scripts infra-lint-terraform infra-lint-workflows ## Lint infra code

infra-lint-markdown: ## Lint Markdown docs for broken links
BASEURL=`pwd`; find . -name \*.md -print0 | xargs -0 -n1 markdown-link-check --config .github/workflows/markdownlint-config.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish it was possible to add comments in Makefiles since I would have loved to have a comment explaining this line for shell noobs like myself.

Optional suggestion: Maybe move this line to ./bin/lint-markdown.sh where we can add comments and explain what it's doing so if anyone needs to update it they are better equipped

Suggested change
BASEURL=`pwd`; find . -name \*.md -print0 | xargs -0 -n1 markdown-link-check --config .github/workflows/markdownlint-config.json
./bin/lint-markdown.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion! It'll also make it easier to add other markdown lints later if we want. In the process of this change, I discovered BASEURL isn't as necessary as I thought. Must default to current working dir or something. Anyways, feel free to take another look and let me know if you have anything thoughts.


infra-lint-scripts: ## Lint shell scripts
shellcheck bin/**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This template assumes that you have an application to deploy. See [application r

After downloading and installing the template into your project:

1. Follow the steps in [`docs/infra/README.md`](./docs/infra/README.md) to setup the infrastructure for your application.
1. Follow the steps in [infra/README.md](/infra/README.md) to setup the infrastructure for your application.
1. After setting up AWS resources, you can [set up GitHub Actions workflows](./template-only-docs/set-up-ci.md).
1. After configuring GitHub Actions, you can [set up continuous deployment](./template-only-docs/set-up-cd.md).
1. At any point, [set up your team workflow](./template-only-docs/set-up-team-workflow.md).
Expand Down
10 changes: 8 additions & 2 deletions docs/infra/set-up-infrastructure-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Then install the version of Terraform you need.
tfenv install 1.4.6
```

If you are unfamiliar with Terraform, check out this [basic introduction to Terraform](./introduction-to-terraform.md).
If you are unfamiliar with Terraform, check out this [basic introduction to Terraform](./intro-to-terraform.md).

### Install AWS CLI

Expand All @@ -44,11 +44,17 @@ brew install gh

### Install linters

[Shellcheck](https://github.com/koalaman/shellcheck) and [actionlint](https://github.com/rhysd/actionlint) are optional utilites for running infrastructure linters locally.
We have several optional utilities for running infrastructure linters locally. These are run as part of the CI pipeline, therefore, it is often simpler to test them locally first.

* [Shellcheck](https://github.com/koalaman/shellcheck)
* [actionlint](https://github.com/rhysd/actionlint)
* [markdown-link-check](https://github.com/tcort/markdown-link-check)

```bash

brew install shellcheck
brew install actionlint
npm install -g markdown-link-check
```

## AWS Authentication
Expand Down
4 changes: 2 additions & 2 deletions template-only-docs/application-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
In order to use the template infrastructure, you need an application that meets the following requirements.

* The application's source code lives in a folder that lives in the project root folder e.g. `/app`.
* The application folder needs to have a `Makefile` that has a build target `release-build` that takes in a Makefile variable `OPTS`, and passes those `OPTS` as options to the `docker build` command. The top level [Makefile](./Makefile) in this repo will call the application's `release-build` make target passing in release tags to tag the docker image with.
* The application folder needs to have a `Makefile` that has a build target `release-build` that takes in a Makefile variable `OPTS`, and passes those `OPTS` as options to the `docker build` command. The top level [Makefile](/Makefile) in this repo will call the application's `release-build` make target passing in release tags to tag the docker image with.
* The web application needs to listen on the port defined by the environment variable `PORT`, rather than hardcode the `PORT`. This allows the infrastructure to configure the application to listen on a container port specified by the infrastructure. See [The Twelve-Factor App](https://12factor.net/) to learn more about designing applications to be portable to different infrastructure environments using environment variables.
* The web application needs to have a health check endpoint at `/health` that returns an HTTP 200 OK response when the application is healthy and ready to accept requests.
* The Docker image needs to have `wget` installed. This is used in the container task defintion's healthcheck configuration in order to ping the application's `/health` endpoint. If you want to use a different healthcheck command (e.g. `curl`) then you'll need to modify the `healthCheck` configuration in the `aws_ecs_task_definition` resource in [modules/service/main.tf](/infra/modules/service/main.tf).
Expand All @@ -22,7 +22,7 @@ If your application needs a database, it must also:

## Example Application

The infra template includes an example "hello, world" application that works with the template. This application is fully deployed and can be viewed at the endpoint <http://app-dev-2068097977.us-east-1.elb.amazonaws.com/>. The source code for this test application is at <https://github.com/navapbc/platform-test>.
The infra template includes an example "hello, world" application that works with the template. This application is fully deployed and can be viewed at the endpoint <http://app-dev-459811935.us-east-1.elb.amazonaws.com/>. The source code for this test application is at <https://github.com/navapbc/platform-test>.

## Template Applications

Expand Down