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

Add pre-commit linting, version checking, and upgrade to Hugo latest (0.126.0) #11872

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.111.0'
hugo-version: '0.126.0'
extended: true

- name: Configure AWS Credentials
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.111.0'
hugo-version: '0.126.0'
extended: true
- name: Run make check_links
run: make check_links
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
# - name: Install Hugo
# uses: peaceiris/actions-hugo@v2
# with:
# hugo-version: '0.111.0'
# hugo-version: '0.126.0'
# extended: true
# - name: Install node
# uses: actions/setup-node@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/esc-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Install Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.111.0'
hugo-version: '0.126.0'
extended: true
- name: Install node
uses: actions/setup-node@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-provider-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Install Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.111.0'
hugo-version: '0.126.0'
extended: true
- name: setup node
uses: actions/setup-node@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.111.0'
hugo-version: '0.126.0'
extended: true

- name: Configure AWS Credentials
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pulumi-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Install Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.111.0'
hugo-version: '0.126.0'
extended: true
- name: Install node
uses: actions/setup-node@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Install Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: "0.111.0"
hugo-version: "0.126.0"
extended: true

- name: Install Pulumi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled-upgrade-programs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Install Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: "0.111.0"
hugo-version: "0.126.0"
extended: true

- name: Install Pulumi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing-build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.111.0'
hugo-version: '0.126.0'
extended: true

- name: Configure AWS Credentials
Expand Down
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "Running pre-commit checks..."
make lint
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ lint:

.PHONY: format
format:
yarn prettier --write .
./scripts/format.sh
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ See also:

We build the Pulumi website with Hugo, manage our dependencies with Node.js and Yarn, and write our documentation in Markdown. Below is a list of the tools you'll need if you'd like to work on the website (e.g., to contribute docs content, a blog post, etc.):

* [Hugo](https://gohugo.io) (>= 0.111.0)
* Hugo 0.111.0 is highly recommended. This is the version we use in our deployment pipelines.
* [Node.js](https://nodejs.org/en/) (>= 18)
* [Yarn](https://classic.yarnpkg.com/en/) (1.x)
* [Hugo](https://gohugo.io/installation/) (>= 0.126.0)
* Hugo 0.126.0 is highly recommended. This is the version we use in our deployment pipelines.
* [Node.js](https://nodejs.org/en/download/package-manager) (>= 18)
* [Yarn](https://classic.yarnpkg.com/lang/en/docs/install) (1.x)

Additionally, to build the SDK and CLI documentation, you'll also need:

Expand Down Expand Up @@ -65,12 +65,12 @@ The `Makefile` exposes a number of useful helpers for authoring:
* `make new-blog-post` scaffolds a new, bare-bones blog post with placeholder content
* `make new-example-program` generates a new multi-language set of examples at `./static/programs`

As a content contributor, the commands you'll most often use are these:
As a content contributor, the commands you'll use most often are these:

```bash
make ensure # Install or update dependencies.
make serve # Run the development server locally on http://localhost:1313.
make lint # Identify any Markdown or code-formatting issues so you an fix them.
make lint # Identify any Markdown or code-formatting issues so you can fix them.
```

## Generating SDK and CLI documentation
Expand Down
3 changes: 1 addition & 2 deletions config/_default/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ security:
- ALGOLIA_APP_SEARCH_KEY

disableKinds:
- category
- taxonomyTerm
- taxonomy

sectionPagesMenu: main
pygmentsCodeFences: true
Expand Down
26 changes: 14 additions & 12 deletions layouts/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
{{ $ancestors = $ancestors | append $a.LinkTitle }}
{{- end -}}

{{-
$index = $index | append (
dict
"objectID" $page.File.UniqueID
"title" $page.Title
"section" $page.Section
"href" $page.RelPermalink
"params" $page.Params
"kind" $page.Kind
"ancestors" (after 1 $ancestors)
)
-}}
{{- if ne $page.File nil -}}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out the only pages that have nil File references are the tag and author pages, whose .UniqueID values already resolve to "" (so are currently being filtered out anyway). So keeping only on those pages that contain File references looks like it's fine after all.

{{-
$index = $index | append (
dict
"objectID" $page.File.UniqueID
"title" $page.Title
"section" $page.Section
"href" $page.RelPermalink
"params" $page.Params
"kind" $page.Kind
"ancestors" (after 1 $ancestors)
)
-}}
{{- end -}}
{{- end -}}
{{- $index | jsonify (dict "indent" " ") -}}
18 changes: 9 additions & 9 deletions layouts/page/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h2 class="text-4xl md:text-6xl bg-white px-6 mb-0 pb-6">We are Pulumi</h2>
<h3 class="font-medium text-6xl">Our purpose</h3>
<h4 class="font-medium text-4-xl">To democratize the cloud for every engineer.</h4>
<p class="text-gray-700 text-xl mb-10">We help engineers ship infrastructure faster with Infrastructure as Code in general-purpose languages.</p>
<a href="{{ relref . " /leadership" }}" class="btn-primary">Meet our leaders</a>
<a href="{{ relref . "/leadership" }}" class="btn-primary">Meet our leaders</a>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Several of these were warning on make serve, so I went ahead and fixed them.

</section>

<section id="what-we-believe" class="text-center text-lg py-8 relative">
Expand Down Expand Up @@ -98,7 +98,7 @@ <h4 class="font-display font-medium">{{ $value.title }}</h4>
</div>
</div>
<div class="careers-cta py-6 w-full mt-28 bg-white">
<h4>Like what we stand for? <a href="{{ relref . " /careers" }}" class="font-bold text-blue-600">Join us.</a></h4>
<h4>Like what we stand for? <a href="{{ relref . "/careers" }}" class="font-bold text-blue-600">Join us.</a></h4>
<p>We are looking for new teammates who want to build the future of cloud infrastructure together.</p>
</div>
</section>
Expand All @@ -119,7 +119,7 @@ <h3 class="font-medium text-6xl">Pulumi is about community</h3>
<img src="/images/mascot/victory-medal-pulumipus.svg" alt="Pulumipus wearing a medal with two hands raised" />
<div class="header mt-6 mb-1.5 text-medium text-2xl">The Puluminaries</div>
<p class="text-left flex-grow">A group for stellar Pulumi community members who have made "above and beyond" contributions to the community.</p>
<a href="{{ relref . " /community/puluminaries" }}" class="btn-primary">Meet our Puluminaries</a>
<a href="{{ relref . "/community/puluminaries" }}" class="btn-primary">Meet our Puluminaries</a>
</div>
<div class="community-spotlight mx-auto flex flex-col justify-cetner items-center w-72 md:w-1/3 my-6 px-3">
<img src="/images/mascot/rocketpus.svg" alt="Pulumipus wearing a medal with two hands raised" />
Expand All @@ -129,9 +129,9 @@ <h3 class="font-medium text-6xl">Pulumi is about community</h3>
</div>
<div class="community-spotlight mx-auto flex flex-col justify-cetner items-center w-72 md:w-1/3 my-6 px-3">
<img src="/images/mascot/hoodie-pulumipus.svg" alt="Pulumipus wearing a Pulumi hoodie" />
<div class="header mt-6 mb-1.5 text-medium text-2xl">Pulumi users</div>
<div class="header /leadershipt-6 mb-1.5 text-medium text-2xl">Pulumi users</div>
<p class="text-left flex-grow">Engineers love Pulumi! Don’t believe us? Check out what our users have to say.</p>
<a href="{{ relref . " /testimonials" }}" class="btn-primary ">Read user quotes</a>
<a href="{{ relref . "/testimonials" }}" class="btn-primary ">Read user quotes</a>
</div>
</div>
</section>
Expand Down Expand Up @@ -226,7 +226,7 @@ <h2 class="font-medium text-6xl mt-10 mb-8">Our awards &amp; recognition</h2>
{{ end }}
</ul>
<div>
<a class="inline-block mt-6 text-bold text-blue-600 mt-12 font-bold" href="{{ relref . " /awards" }}">View all achievements</a>
<a class="inline-block mt-6 text-bold text-blue-600 mt-12 font-bold" href="{{ relref . "/awards" }}">View all achievements</a>
</div>
</div>
</section>
Expand All @@ -248,7 +248,7 @@ <h5 class="mt-2 mb-0">{{ .title }}</h5>
</li>
{{ end }}
</ul>
<a class="text-blue-600 font-bold" href="{{ relref . " /newsroom" }}">View all press releases</a>
<a class="text-blue-600 font-bold" href="{{ relref . "/newsroom" }}">View all press releases</a>
</div>
<div class="md:w/1-2 md:px-8">
<h3 class="text-center md:text-left font-medium text-6xl">Recent News</h3>
Expand All @@ -262,7 +262,7 @@ <h5 class="mt-2 mb-0">{{ .title }}</h5>
</li>
{{ end }}
</ul>
<a class="text-blue-600 font-bold" href="{{ relref . " /newsroom" }}">View all recent news</a>
<a class="text-blue-600 font-bold" href="{{ relref . "/newsroom" }}">View all recent news</a>
</div>
</div>
</section>
Expand All @@ -275,6 +275,6 @@ <h5 class="mt-2 mb-0">{{ .title }}</h5>
<h3 class="font-medium text-6xl">Join our team</h3>
<h4>We are fully remote and hiring!</h4>
<p class="mb-9">Our team is a diverse and talented group of individuals from all walks of life.</p>
<a href="{{ relref . " /careers" }}" class="btn-primary">Browse open positions</a>
<a href="{{ relref . "/careers" }}" class="btn-primary">Browse open positions</a>
</section>
{{ end }}
2 changes: 1 addition & 1 deletion layouts/page/leadership.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{{ define "main" }}
<div class="container mx-auto mt-12 max-w-7xl">
<a class="text-blue-600 text-xl font-body ml-9 hidden sm:block" href="{{ relref . " /about" }}">
<a class="text-blue-600 text-xl font-body ml-9 hidden sm:block" href="{{ relref . "/about" }}">
<i class="fas fa-arrow-left mr-4"></i>
About
</a>
Expand Down
2 changes: 1 addition & 1 deletion layouts/product/pulumi-cloud.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ <h5>{{ $item.title }}</h5>
<h2>{{ .title }}</h2>
<p class="max-w-xl mx-auto">{{ .description | markdownify }}</p>
<div class="mt-12">
<a href="{{ relref $pageContext " /pricing" }}" class="btn-secondary">Pricing</a>
<a href="{{ relref $pageContext "/pricing" }}" class="btn-secondary">Pricing</a>
</div>
{{ end }}
</section>
Expand Down
2 changes: 1 addition & 1 deletion layouts/product/pulumi-insights.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h4 class="p-0 m-0 text-gray-800">{{ .subtitle }}</h4>
<h2>{{ .title }}</h2>
<p class="max-w-2xl mx-auto">{{ .description | markdownify }}</p>
<div class="mt-12">
<a href="{{ relref $pageContext " /pricing" }}" class="btn-secondary">View Pricing</a>
<a href="{{ relref $pageContext "/pricing" }}" class="btn-secondary">View Pricing</a>
</div>
{{ end }}
</section>
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"private": true,
"license": "Apache-2.0",
"scripts": {
"minify-css": "node scripts/minify-css.js"
"minify-css": "node scripts/minify-css.js",
"prepare": "husky"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.427.0",
Expand Down Expand Up @@ -34,6 +35,7 @@
"typescript": "^4.9.5"
},
"devDependencies": {
"husky": "^9.0.11",
"prettier": "^2.6.2"
}
}
36 changes: 28 additions & 8 deletions scripts/ensure.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
#!/bin/bash

# Make sure the Node version matches what's in .nvmrc (and in our GitHub Actions workflows).
current_version="$(node -v)"
required_version="$(cat .nvmrc)"
set -o errexit -o pipefail

if [ ! $(echo ${current_version} | grep ${required_version}) ]; then
printf "\nIt looks like you're running Node %s, but this project uses Node %s.\n" ${current_version} ${required_version}
printf "If you're using nvm, try running nvm use.\n\n"
exit 1
fi
check_version() {
tool_name="$1"
executable="$2"
version_string="$(eval $3)"
required_version="$4"
level="$5"

color_red=$(echo -e "\033[0;31m")
color_yellow=$(echo -e "\033[0;33m")
color_end=$(echo -e "\033[0m")

details="See the README at https://github.com/pulumi/docs for a list of required tools and versions."

if ! command -v "$executable" &> /dev/null; then
echo -e "${color_red}error${color_end} This project requires $1, but the '$2' executable is either not installed or not on your PATH."
echo $details
exit 1
fi

if [ ! $(echo ${version_string} | grep ${required_version}) ]; then
printf "${color_yellow}warning${color_end} It looks like you're running %s %s, but this project uses version %s.\n" ${tool_name} ${version_string} ${required_version}
echo $details
fi
}
check_version "Node.js" "node" "node -v | sed 's/v\([0-9\.]*\).*$/\1/'" "18"
check_version "Hugo" "hugo" "hugo version | sed 's/hugo v\([0-9\.]*\).*$/\1/'" "0.126.0"
check_version "Yarn" "yarn" "yarn -v | sed 's/v\([0-9\.]*\).*$/\1/'" "1.22"
Comment on lines +29 to +31
Copy link
Contributor Author

@cnunciato cnunciato May 20, 2024

Choose a reason for hiding this comment

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

It'd be awesome if we could specify these versions in one place and use them everywhere. Don't yet have any great ideas for how to do this in a way that's work both locally and in our GHA workflows, though. 🤔

Copy link
Member

Choose a reason for hiding this comment

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

for hugo not sure, but I wouldn't be surprised if there is a way to enforce the node and yarn versions in the package.json file somehow.


# Install the Node dependencies for the website and the infrastructure.
yarn install
Expand Down
5 changes: 5 additions & 0 deletions scripts/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -o errexit -o pipefail

yarn prettier --write .
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2894,6 +2894,11 @@ humanize-duration@^3.9.1:
resolved "https://registry.yarnpkg.com/humanize-duration/-/humanize-duration-3.27.3.tgz#db654e72ebf5ccfe232c7f56bc58aa3a6fe4df88"
integrity sha512-iimHkHPfIAQ8zCDQLgn08pRqSVioyWvnGfaQ8gond2wf7Jq2jJ+24ykmnRyiz3fIldcn4oUuQXpjqKLhSVR7lw==

husky@^9.0.11:
version "9.0.11"
resolved "https://registry.yarnpkg.com/husky/-/husky-9.0.11.tgz#fc91df4c756050de41b3e478b2158b87c1e79af9"
integrity sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==

[email protected]:
version "0.6.3"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501"
Expand Down
Loading