Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Really add AWSx docs fixes this time (#3674)
Browse files Browse the repository at this point in the history
* Revert "Revert "Update the AWS Guides index page""

This reverts commit 668aa2e.

* Fix program-install bug

* Add all programs

* Ignore program files for linting (for now)

* Actually don't do that

* Add missing app folders, have make ensure enable go.mods

* Add a target to test end to end

* One more of these, just so there's no confusion

* Update runtime vesions appropriately

* Bring Hugo back down to 111
  • Loading branch information
cnunciato authored Nov 30, 2023
1 parent a361345 commit f15210a
Show file tree
Hide file tree
Showing 136 changed files with 3,301 additions and 2,133 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Install Hugo
uses: peaceiris/actions-hugo@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Install Hugo
uses: peaceiris/actions-hugo@v2
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/scheduled-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Run tests
on:
schedule:
- cron: "0 8 * * *"
workflow_dispatch: {}

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULUMI_TEST_OWNER: "moolumi"
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
AWS_REGION: "us-west-2"
PULUMI_API: https://api.pulumi-staging.io

jobs:
test:
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform:
- ubuntu-latest
go-version:
- 1.18.x
node-version:
- 18.x
python-version:
- 3.8
dotnet-version:
- 6.0.x
java-version:
- 11

steps:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Install Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{ matrix.java-version }}

- name: Install DotNet
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Install Pulumi
uses: pulumi/actions@v4

- name: Check out the code
uses: actions/checkout@v3

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-region: ${{ env.AWS_REGION }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-duration-seconds: 14400 # 4 hours
role-session-name: pulumi-hugo-examples@githubActions
role-to-assume: ${{ secrets.AWS_CI_ROLE_ARN }}

- name: Run the tests
run: make test
8 changes: 8 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/usr/bin/env sh

. "$(dirname -- "$0")/_/husky.sh"

. ./scripts/common.sh

yarn run lint-staged

./scripts/lint/check-file-size.sh

# Fix up any go.mod files included in example programs.
clean_gomods
suffix_gomods
git add "themes/default/static/programs/**/go.mod.txt" || true
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ format:
build:
./scripts/build.sh

.PHONY: test
test:
./scripts/test.sh preview

.PHONY: test-full
test-full:
./scripts/test.sh update

.PHONY: ci-build-full-site
ci-build-full-site:
./scripts/ci/build-full-site.sh
Expand Down
16 changes: 1 addition & 15 deletions scripts/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,4 @@ set -o errexit -o pipefail

yarn cache clean
hugo mod clean

rm -rf _vendor
rm -rf public
rm -rf node_modules
rm -rf themes/default/theme/node_modules

for dir in themes/* ; do
pushd $dir
hugo mod clean
rm -rf resources
rm -rf node_modules
rm -rf static/js
rm -rf static/css
popd
done
git clean -fdX
31 changes: 31 additions & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
#!/bin/bash

export REPO_THEME_PATH="themes/default/"

suffix_gomods() {
for file in $(find ./themes/default/static/programs/* -name 'go.mod' -not -path "**/node_modules/**")
do
cp $file $(echo "$file" | sed -r 's|.mod|.mod.txt|g')
done
}

unsuffix_gomods() {
for file in $(find ./themes/default/static/programs/* -name 'go.mod.txt' -not -path "**/node_modules/**" )
do
cp $file $(echo "$file" | sed -r 's|.mod.txt|.mod|g')
done
}

clean_gomods() {
local requires=0
local i=0

for file in $(find ./themes/default/static/programs/* -name 'go.mod*' -not -path "**/node_modules/**" )
do
new_file="$(cat $file)"
split_at="$(awk '/require/{i++; if (i==2) { print NR-1; exit }}' $file)"

if [[ "$split_at" != "" ]]; then
new_file="$(cat $file | head -n $split_at)"
fi

echo "$new_file" > "$file"
done
}
3 changes: 3 additions & 0 deletions scripts/ensure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ echo "Installing Node.js modules..."
yarn install
yarn --cwd ./themes/default/theme install
yarn --cwd ./themes/default/theme/stencil install

# Prep Go projects so they're immediately runnable.
unsuffix_gomods
3 changes: 3 additions & 0 deletions scripts/serve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ set -o errexit -o pipefail

source ./scripts/common.sh

# Prep Go projects so they're immediately runnable.
unsuffix_gomods

# Just run Hugo.
HUGO_BASEURL=http://localhost:1313 hugo serve --buildDrafts --buildFuture | grep -v -e 'WARN .* REF_NOT_FOUND'
76 changes: 75 additions & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,77 @@
#!/bin/bash

yarn --cwd themes/default test
set -o errexit -o pipefail

source ./scripts/common.sh

pulumi whoami -v

#
# Run program tests.
#

# Delete install artifacts (but leave any existing go.mod files in place so we can use them.)
find ./themes/default/static/programs/* -name 'node_modules' | xargs rm -rf
find ./themes/default/static/programs/* -name 'go.sum' | xargs rm -f
find ./themes/default/static/programs/* -name 'package-lock.json' | xargs rm -f

# Fix up go.mod files.
clean_gomods
unsuffix_gomods

pushd themes/default/static/programs
for dir in */; do
project="$(basename $dir)"

echo "***"
echo "* $project"
echo "***"

org="$(pulumi whoami -v --json | jq -r .user)"
stack="dev"
fqsn="${org}/${project}/${stack}"

# Install dependencies.
pulumi -C "$project" install

# Skip certain programs known not to work.

# Java examples of FargateService erroneously complain about missing container declarations.
# https://github.com/pulumi/pulumi-awsx/issues/820
if [[ "$project" == "awsx-vpc-fargate-service-java" ]]; then
continue
elif [[ "$project" == "awsx-load-balanced-fargate-ecr-java" ]]; then
continue
elif [[ "$project" == "awsx-load-balanced-fargate-nginx-java" ]]; then
continue
fi

# Destroy any existing stacks.
pulumi -C "$project" cancel --stack $fqsn --yes || true
pulumi -C "$project" destroy --stack $fqsn --yes --refresh --remove || true

# Delete any existing Docker images.
# docker rmi -f "$(docker images -aq)" || true

# Create a new stack.
pulumi -C "$project" stack select $fqsn || pulumi -C "$project" stack init $fqsn
pulumi -C "$project" config set aws:region us-west-2 || true

# Preview or deploy.
if [[ "$1" == "update" ]]; then
pulumi -C "$project" up --yes
else
pulumi -C "$project" preview
fi

# Destroy and remove.
pulumi -C "$project" destroy --yes --remove

done
popd

clean_gomods
suffix_gomods

# Delete build/test artifacts.
git clean -fdX themes/default/static/examples
Loading

0 comments on commit f15210a

Please sign in to comment.