Skip to content

Commit 0f630d5

Browse files
authored
Check markdown link versions (#20)
1 parent 69e5579 commit 0f630d5

File tree

7 files changed

+42
-23
lines changed

7 files changed

+42
-23
lines changed

.buildkite/check-latest-tag.sh

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function finish() {
66
}
77
trap finish EXIT
88

9-
set -ex
9+
set -e -o pipefail
1010

1111
cd "$(dirname "${BASH_SOURCE[0]}")"/..
1212

@@ -23,11 +23,30 @@ get_latest() {
2323

2424
latest="$(get_latest)"
2525

26-
git grep --line-number "# LATEST" examples >"$scratch/want.txt" || true
27-
git grep --line-number "\"$latest\" # LATEST" examples >"$scratch/got.txt" || true
26+
check_versions() {
27+
file_pattern="$1"
28+
all_regex="$2"
29+
correct_regex="$3"
30+
find . -name "$file_pattern" -print0 | xargs -0 grep -n "$all_regex" >"$scratch/all.txt" || true
31+
find . -name "$file_pattern" -print0 | xargs -0 grep -n "$correct_regex" >"$scratch/correct.txt" || true
32+
if ! (git diff --color -U0 --no-index --exit-code "$scratch/all.txt" "$scratch/correct.txt" | tail -n +6); then
33+
echo ""
34+
echo "❌ Detected out of sync versions in the lines above (should be version $latest)"
35+
exit 1
36+
fi
37+
}
38+
39+
check_versions \
40+
"*.tf" \
41+
"# LATEST" \
42+
"\"$latest\" # LATEST"
43+
44+
check_versions \
45+
"*.md" \
46+
"https://registry.terraform.io/modules/sourcegraph/executors/aws/[0-9]\+\.[0-9]\+\.[0-9]\+" \
47+
"https://registry.terraform.io/modules/sourcegraph/executors/aws/$latest"
2848

29-
if ! git diff --no-index --exit-code "$scratch/want.txt" "$scratch/got.txt"; then
30-
echo ""
31-
echo "❌ Detected old versions! Make sure that all versions \`version = \"...\" # LATEST\` match the latest git tag: $latest"
32-
exit 1
33-
fi
49+
check_versions \
50+
"*.md" \
51+
"https://github.com/sourcegraph/terraform-aws-executors/blob/v[0-9]\+\.[0-9]\+\.[0-9]\+" \
52+
"https://github.com/sourcegraph/terraform-aws-executors/blob/v$latest"

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ This repository provides a [Terraform module](https://learn.hashicorp.com/tutori
66

77
This repository provides four submodules:
88

9-
1. The [executors module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/executors) provisions compute resources for executors.
10-
1. The [docker-mirror module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/docker-mirror) provisions a Docker registry pull-through cache.
11-
1. The [networking module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/networking) provisions a network to be shared by the executor and Docker registry resources.
12-
1. The [credentials module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/credentials) provisions credentials required by the Sourcegraph instance to enable observability and auto-scaling of executors.
9+
1. The [executors module](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21/submodules/executors) provisions compute resources for executors.
10+
1. The [docker-mirror module](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21/submodules/docker-mirror) provisions a Docker registry pull-through cache.
11+
1. The [networking module](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21/submodules/networking) provisions a network to be shared by the executor and Docker registry resources.
12+
1. The [credentials module](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21/submodules/credentials) provisions credentials required by the Sourcegraph instance to enable observability and auto-scaling of executors.
1313

14-
The [multiple-executors example](https://github.com/sourcegraph/terraform-aws-executors/blob/master/examples/multiple-executors) uses the submodule directly to provision multiple executor resource groups performing different types of work. Follow this example if you are:
14+
The [multiple-executors example](https://github.com/sourcegraph/terraform-aws-executors/blob/v0.0.21/examples/multiple-executors) uses the submodule directly to provision multiple executor resource groups performing different types of work. Follow this example if you are:
1515

1616
1. Provisioning executors for use with multiple features (e.g., both [auto-indexing](https://docs.sourcegraph.com/code_intelligence/explanations/auto_indexing) and [server-side batch changes](https://docs.sourcegraph.com/batch_changes/explanations/server_side)), or
1717
1. Provisioning resources for multiple Sourcegraph instances (e.g., test, prod)
1818

19-
This repository also provides a [root module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest) combining the executors, network, and docker-mirror resources into an easier to use package.
19+
This repository also provides a [root module](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21) combining the executors, network, and docker-mirror resources into an easier to use package.
2020

21-
The [single-executor example](https://github.com/sourcegraph/terraform-aws-executors/blob/master/examples/single-executor) uses the root module to provision a single executor type. Follow this example if you are deploying to a single Sourcegraph instance and using a single executors-backed feature.
21+
The [single-executor example](https://github.com/sourcegraph/terraform-aws-executors/blob/v0.0.21/examples/single-executor) uses the root module to provision a single executor type. Follow this example if you are deploying to a single Sourcegraph instance and using a single executors-backed feature.
2222

2323
## Requirements
2424

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Multiple executor example
22

3-
This example uses [networking](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/networking), [docker-mirror](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/docker-mirror), and [executors](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/executors) submodules that provision a network, a Docker registry mirror, and sets of resources running one or more types of executors.
3+
This example uses [networking](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21/submodules/networking), [docker-mirror](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21/submodules/docker-mirror), and [executors](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21/submodules/executors) submodules that provision a network, a Docker registry mirror, and sets of resources running one or more types of executors.
44

55
The following variables must be supplied:
66

@@ -10,4 +10,4 @@ The following variables must be supplied:
1010

1111
If your deployment environment already has a Docker registry that can be used, only the `executor` submodule must be used (and references to the `networking` and `docker-mirror` modules can be dropped). The Docker registry mirror address can be supplied along with its containing VPC and subnet as pre-existing identifier literals.
1212

13-
All of these module's variables are defined in [modules/networking/variables.tf](https://github.com/sourcegraph/terraform-aws-executors/blob/master/modules/networking/variables.tf), [modules/docker-mirror/variables.tf](https://github.com/sourcegraph/terraform-aws-executors/blob/master/modules/docker-mirror/variables.tf), and [modules/executors/variables.tf](https://github.com/sourcegraph/terraform-aws-executors/blob/master/modules/executors/variables.tf).
13+
All of these module's variables are defined in [modules/networking/variables.tf](https://github.com/sourcegraph/terraform-aws-executors/blob/v0.0.21/modules/networking/variables.tf), [modules/docker-mirror/variables.tf](https://github.com/sourcegraph/terraform-aws-executors/blob/v0.0.21/modules/docker-mirror/variables.tf), and [modules/executors/variables.tf](https://github.com/sourcegraph/terraform-aws-executors/blob/v0.0.21/modules/executors/variables.tf).

examples/single-executor/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Single executor example
22

3-
This example uses the [root module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest) that provisions a network, a Docker registry mirror, and a set of resources to run _one_ type of executor. To provision more than one type of executor (multiple queues or multiple environments), see the following `multiple-executors` example.
3+
This example uses the [root module](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21) that provisions a network, a Docker registry mirror, and a set of resources to run _one_ type of executor. To provision more than one type of executor (multiple queues or multiple environments), see the following `multiple-executors` example.
44

55
The following variables must be supplied:
66

@@ -12,4 +12,4 @@ The following variables must be supplied:
1212
- `executor_metrics_environment_label`: The name of the target environment (e.g., `staging`, `prod`). This value must be the same as the `EXECUTOR_METRIC_ENVIRONMENT_LABEL` environment variable as described in [Configuring auto scaling](https://docs.sourcegraph.com/admin/deploy_executors#aws).
1313
- `executor_instance_tag`: Compute instances are tagged by this value by the key `executor_tag`. We recommend this value take the form `{executor_queue_name}-{executor_metrics_environment_label}`. This value must be the same as `INSTANCE_TAG` as described in [Configuring observability](https://docs.sourcegraph.com/admin/deploy_executors#aws-1).
1414

15-
All of this module's variables are defined in [variables.tf](https://github.com/sourcegraph/terraform-aws-executors/blob/master/variables.tf).
15+
All of this module's variables are defined in [variables.tf](https://github.com/sourcegraph/terraform-aws-executors/blob/v0.0.21/variables.tf).

modules/docker-mirror/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
This module provides a hosted Docker registry pull-through cache to be used by [Sourcegraph executor](https://docs.sourcegraph.com/admin/executors). It is strongly recommended to deploy a Docker mirror as a cache to reduce rate limiting by the public [Docker Hub registry](https://hub.docker.com/). We have also seen deploying a Docker mirror in the same physical zone as the executors significantly decreased latencies during image pulls.
44

5-
When using the sibling [executors module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/executors), the `vpc_id` and `subnet_id` values must match and the executor module `docker_registry_mirror` value should match `"http://${static_ip}:5000"`.
5+
When using the sibling [executors module](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21/submodules/executors), the `vpc_id` and `subnet_id` values must match and the executor module `docker_registry_mirror` value should match `"http://${static_ip}:5000"`.

modules/executors/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Executors module
22

3-
This module provides the resources to provision [Sourcegraph executor](https://docs.sourcegraph.com/admin/executors) compute resources on AWS. For a high-level overview of the resources deployed by this module, see the [root module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest). This module includes the following resources:
3+
This module provides the resources to provision [Sourcegraph executor](https://docs.sourcegraph.com/admin/executors) compute resources on AWS. For a high-level overview of the resources deployed by this module, see the [root module](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21). This module includes the following resources:
44

55
- AWS launch template
66
- AWS autoscaler and autoscaling policy
@@ -10,4 +10,4 @@ This module provides the resources to provision [Sourcegraph executor](https://d
1010

1111
This module does **not** automatically create networking or Docker mirror resources. The `vpc_id`, `subnet_id`, and `docker_registry_mirror` variables must be supplied explicitly with resources that have been previously created.
1212

13-
This module is often used with the sibling modules that create [networking](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/networking) and [Docker mirror](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/docker-mirror) resources which can be shared by multiple instances of the executor module (listening to different queues or being deployed in a different environment).
13+
This module is often used with the sibling modules that create [networking](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21/submodules/networking) and [Docker mirror](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21/submodules/docker-mirror) resources which can be shared by multiple instances of the executor module (listening to different queues or being deployed in a different environment).

modules/networking/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Networking module
22

3-
This module provides the networking glue between the sibling [executors](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/executors) and [docker-mirror](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/docker-mirror) modules.
3+
This module provides the networking glue between the sibling [executors](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21/submodules/executors) and [docker-mirror](https://registry.terraform.io/modules/sourcegraph/executors/aws/0.0.21/submodules/docker-mirror) modules.
44

55
_(There's very little to talk about in here.)_

0 commit comments

Comments
 (0)