From 30ba0afc34943394229f93e06ce0413a4b61ee18 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Tue, 20 Aug 2019 21:25:58 -0400 Subject: [PATCH 1/8] fix: add new path to legacy git mappings --- php-config/Git.config.d/codeforphilly.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/php-config/Git.config.d/codeforphilly.php b/php-config/Git.config.d/codeforphilly.php index 3f0c2208..5320de1b 100644 --- a/php-config/Git.config.d/codeforphilly.php +++ b/php-config/Git.config.d/codeforphilly.php @@ -11,7 +11,8 @@ 'newsletters', 'php-classes', 'php-config/Git.config.d', + 'php-config/Laddr', 'php-config/Laddr.config.d', 'site-root' ] -]; \ No newline at end of file +]; From 372e6858e1f0031393bb4c781aa01f09c00445ba Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Sun, 31 Jan 2021 05:40:21 +0000 Subject: [PATCH 2/8] feat: add studio --- .../emergence-site/_codeforphilly.toml | 6 +- .studiorc | 19 +++- script/-studio-bootstrap | 91 +++++++++++++++++++ script/studio | 67 ++++++++++++++ 4 files changed, 181 insertions(+), 2 deletions(-) create mode 100755 script/-studio-bootstrap create mode 100755 script/studio diff --git a/.holo/branches/emergence-site/_codeforphilly.toml b/.holo/branches/emergence-site/_codeforphilly.toml index 3897826f..4c3d8219 100644 --- a/.holo/branches/emergence-site/_codeforphilly.toml +++ b/.holo/branches/emergence-site/_codeforphilly.toml @@ -1,3 +1,7 @@ [holomapping] -files = "*/**" +files = [ + "*/**", + "!cypress/**", + "!script/**", +] after = "*" diff --git a/.studiorc b/.studiorc index 66daba17..0935aa1a 100644 --- a/.studiorc +++ b/.studiorc @@ -1,3 +1,20 @@ #!/bin/bash -hab pkg install emergence/studio + +# install dependent studios +hab pkg install emergence/studio jarvus/mkdocs-studio + +# disable studios printing their own help +export STUDIO_NOHELP="yes" + source "$(hab pkg path emergence/studio)/studio.sh" + +export DOCS_HOLOBRANCH="docs-site" +source "$(hab pkg path jarvus/mkdocs-studio)/studio.sh" + + +## final init and output +studio-help + + +# final blank line +echo diff --git a/script/-studio-bootstrap b/script/-studio-bootstrap new file mode 100755 index 00000000..7f3c8ac5 --- /dev/null +++ b/script/-studio-bootstrap @@ -0,0 +1,91 @@ +#!/bin/bash + +# script/-studio-bootstrap: Check dependencies for Chef Habitat studio. + +set -e +cd "$(dirname "$0")/.." + + +echo +echo "==> studio-bootstrap: verifying Docker…" + +if ! [ -x "$(command -v docker)" ]; then + echo "Please install Docker Engine: https://docs.docker.com/engine/install/" + exit 1 +fi + +if ! docker info > /dev/null 2>&1; then + echo "Docker Engine is not running, or your user does not have access to connect." + echo "Try starting Docker Engine, and adding your user to the docker group: sudo gpasswd -a $USER docker" + exit 1 +fi + + +echo +echo "==> studio-bootstrap: verifying Chef Habitat…" + +if ! [ -x "$(command -v hab)" ]; then + echo "Please install Chef Habitat: https://www.habitat.sh/docs/install-habitat/" + exit 1 +fi + +set +e +hab_version="$(hab --version < /dev/null)" +if [ $? -ne 0 ]; then + echo + echo " Failed to read hab version, you may need to accept the Chef Habitat" + echo " license. Please run \`hab setup\` or configure HAB_LICENSE in the environment" + exit 1 +fi +set -e + +if ! [[ $hab_version =~ ^hab[[:space:]][0-9]+\.[0-9]+\.[0-9]+/[0-9]+$ ]]; then + echo + echo " Could not parse hab version: ${hab_version}" + echo " Please install hab 1.6+" + exit 1 +fi + +hab_version="$(echo "${hab_version}" | awk '{print $2}' | awk -F'/' '{print $1}')" +echo " Found hab version: ${hab_version}" + + +# check that node >= MAJOR.MINOR +hab_min_major="1" +hab_min_minor="6" + +IFS='.' read -ra hab_version_split <<< "${hab_version#v}" +if [ "${hab_version_split[0]}" -lt "${hab_min_major}" ] || [[ "${hab_version_split[0]}" -le "${hab_min_major}" && "${hab_version_split[1]}" -lt "${hab_min_minor}" ]]; then + echo + echo " Please install hab >= ${hab_min_major}.${hab_min_minor}.x" + exit 1 +fi + +if ! [ -f ~/.hab/etc/cli.toml ] || ! grep -q '^origin =' ~/.hab/etc/cli.toml; then + echo "Please re-run \`hab setup\` and choose to set a default origin, it can be anything" + exit 1 +fi + +_origin=$(awk -F'"' '/^origin = /{print $2}' ~/.hab/etc/cli.toml) + + +echo +echo "==> studio-bootstrap: verifying origin '${_origin}'…" + +_root_owned_key_count=$(ls -l ~/.hab/cache/keys | cut -f 3,4 -d " " | grep "root root" | wc -l) + +if [ "$_root_owned_key_count" -gt 0 ]; then + echo "Working around: https://github.com/habitat-sh/habitat/issues/7737" + echo "Found ${_root_owned_key_count} keys owned by root. Chowning them to $USER:$USER." + sudo chown $USER:$USER ~/.hab/cache/keys/* +fi + +if ! hab origin key export --type secret "${_origin}" > /dev/null; then + echo "No key has been generated for origin ${_origin}, run: hab origin key generate ${_origin}" + exit 1 +fi + + +echo +echo "==> studio-bootstrap: all set 👍" +echo diff --git a/script/studio b/script/studio new file mode 100755 index 00000000..ab59bc49 --- /dev/null +++ b/script/studio @@ -0,0 +1,67 @@ +#!/bin/sh + +# script/studio: Enter a Chef Habitat studio for the application. + +set -e +cd "$(dirname "$0")/.." + + +script/-studio-bootstrap + + +unset DEBUG +[ -n "${1}" ] && cd "${1}" + + +echo +echo "==> studio: configuring Chef Habitat studio Docker options…" +STUDIO_NAME="${STUDIO_NAME:-codeforphilly-studio}" +export HAB_DOCKER_OPTS=" + --name ${STUDIO_NAME} + -p 9080:80 + -p 9088:8000 + -p 9086:3306 + -v $(cd ~/.ssh; pwd)/known_hosts:/root/.ssh/known_hosts:ro + --env STUDIO_DEVELOPER_UID=$(id -u) + --env STUDIO_DEVELOPER_GID=$(id -g) +" +echo "${HAB_DOCKER_OPTS}" + + +launch_studio=true +if [ "$(docker ps -aq -f name="${STUDIO_NAME}")" ]; then + echo + echo "==> studio: a ${STUDIO_NAME} container is already running…" + echo + while true; do + read -p "==> studio: would you like to (A)ttach to it, (s)top it, or do (n)othing? [A/s/n] " choice + case "${choice}" in + r|R|a|A|"") + echo + echo "==> studio: you can run studio-help at anytime to get a list of commands" + echo + docker attach "${STUDIO_NAME}" + launch_studio=false + break;; + s|S) + echo "==> studio: stopping existing container…" + docker stop "${STUDIO_NAME}" > /dev/null + break;; + n|N) + echo "==> studio: doing nothing with existing container… an error is likely to occur" + break ;; + *) + echo "==> studio: $choice is invalid";; + esac + done +fi + +if [ $launch_studio = true ]; then + echo + echo "==> studio: launching Docker-powered Chef Habitat studio…" + set +e + if ! hab studio enter -D; then + echo "===> studio: failed to launch studio… try executing the following and try again:" + echo "docker rm -f ${STUDIO_NAME}" + fi +fi From 9360b5d14caa2091a955ef5e2c1aa4e872fdbb0e Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Wed, 25 Aug 2021 02:12:33 +0000 Subject: [PATCH 3/8] refactor(ci): update gh workflow naming/format --- .github/workflows/publish-docs.yml | 20 ++++++++++++++++++++ .github/workflows/publish-holobranches.yml | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/publish-docs.yml create mode 100644 .github/workflows/publish-holobranches.yml diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml new file mode 100644 index 00000000..6f34c4ad --- /dev/null +++ b/.github/workflows/publish-docs.yml @@ -0,0 +1,20 @@ +name: Publish Docs + +on: + push: + branches: [ develop ] + +jobs: + + publish-docs: + runs-on: ubuntu-latest + steps: + + - name: 'Update holobranch: gh-pages' + uses: JarvusInnovations/hologit@actions/projector/v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HAB_LICENSE: accept + with: + holobranch: docs-site + commit-to: gh-pages diff --git a/.github/workflows/publish-holobranches.yml b/.github/workflows/publish-holobranches.yml new file mode 100644 index 00000000..0bd35532 --- /dev/null +++ b/.github/workflows/publish-holobranches.yml @@ -0,0 +1,20 @@ +name: Publish Holobranches + +on: + push: + tags: [ 'v1.*' ] + +jobs: + + publish-holobranches: + runs-on: ubuntu-latest + steps: + + - name: 'Update holobranch: emergence/site/v1' + uses: JarvusInnovations/hologit@actions/projector/v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HAB_LICENSE: accept + with: + holobranch: emergence-site + commit-to: emergence/site/v1 From 8fd5809e65258457ba53778d464b192b1c76d222 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Wed, 25 Aug 2021 03:00:17 +0000 Subject: [PATCH 4/8] feat(ci): add GitHub release workflows --- .github/workflows/release-deploy.yml | 43 ++++++++++ .github/workflows/release-prepare.yml | 113 +++++++++++++++++++++++++ .github/workflows/release-validate.yml | 34 ++++++++ 3 files changed, 190 insertions(+) create mode 100644 .github/workflows/release-deploy.yml create mode 100644 .github/workflows/release-prepare.yml create mode 100644 .github/workflows/release-validate.yml diff --git a/.github/workflows/release-deploy.yml b/.github/workflows/release-deploy.yml new file mode 100644 index 00000000..c4d98477 --- /dev/null +++ b/.github/workflows/release-deploy.yml @@ -0,0 +1,43 @@ +name: 'Release: Deploy PR' + +on: + pull_request: + branches: [ 'releases/v*' ] + types: [ closed ] + +jobs: + release-deploy: + + if: github.event.pull_request.merged == true # only run on PR merge + runs-on: ubuntu-latest + steps: + + - name: Configure release + run: | + PR_TITLE=$(jq -r ".pull_request.title" $GITHUB_EVENT_PATH) + PR_BODY=$(jq -r ".pull_request.body" $GITHUB_EVENT_PATH) + RELEASE_TAG=$(echo "${PR_TITLE}" | grep -oP "(?<=^Release: )v\d+\.\d+\.\d+(-rc\.\d+)?$") + + if [[ "${RELEASE_TAG}" =~ -rc\.[0-9]+$ ]]; then + RELEASE_PRERELEASE=true + else + RELEASE_PRERELEASE=false + fi + + echo "PR_TITLE=${PR_TITLE}" >> $GITHUB_ENV + echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV + echo "RELEASE_PRERELEASE=${RELEASE_PRERELEASE}" >> $GITHUB_ENV + + echo 'PR_BODY<> $GITHUB_ENV + echo "${PR_BODY}" >> $GITHUB_ENV + echo 'END_OF_PR_BODY' >> $GITHUB_ENV + + - name: Create release + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.BOT_GITHUB_TOKEN }} + commit: '${{ github.sha }}' + tag: '${{ env.RELEASE_TAG }}' + body: '${{ env.PR_BODY }}' + draft: false + prerelease: ${{ env.RELEASE_PRERELEASE }} diff --git a/.github/workflows/release-prepare.yml b/.github/workflows/release-prepare.yml new file mode 100644 index 00000000..8770094c --- /dev/null +++ b/.github/workflows/release-prepare.yml @@ -0,0 +1,113 @@ +name: 'Release: Prepare PR' + +on: + push: + branches: [ develop ] + +env: + GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} + RELEASE_BRANCH: releases/v1 + +jobs: + release-prepare: + + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + # - uses: mxschmitt/action-tmate@v3 + + - name: Create/update pull request + run: | + # get latest release tag + latest_release=$(git describe --tags --abbrev=0 "origin/${RELEASE_BRANCH}") + latest_release_bumped=$(echo $latest_release | awk -F. -v OFS=. '{$NF++;print}') + + + # create or update PR + pr_body="$(cat < /tmp/pr.json + pr_number=$(hub pr list -h develop -f '%I') + echo "Opened PR #${pr_number}" + fi + + + # build changelog + commits=$( + git log \ + --first-parent \ + --reverse \ + --format="%H" \ + "origin/${RELEASE_BRANCH}..develop" + ) + + changelog=() + + while read -r commit; do + subject="$(git show -s --format=%s "${commit}")" + line="" + + if [[ "${subject}" =~ Merge\ pull\ request\ \#([0-9]+) ]]; then + line="$(hub pr show -f '%t [%i] @%au' "${BASH_REMATCH[1]}" || true)" + fi + + if [ -z "${line}" ]; then + author="$(hub api "/repos/${GITHUB_REPOSITORY}/commits/${commit}" -H Accept:application/vnd.github.v3+json | jq -r '.author.login')" + if [ -n "${author}" ]; then + author="@${author}" + else + author="$(git show -s --format=%ae "${commit}")" + fi + + line="${subject} ${author}" + fi + + # move ticket number prefix into to existing square brackets at end + line="$(echo "${line}" | perl -pe 's/^([A-Z]+-[0-9]+):?\s*(.*?)\s*\[([^]]+)\]\s*(\S+)$/\2 [\3, \1] \4/')" + + # move ticket number prefix into to new square brackets at end + line="$(echo "${line}" | perl -pe 's/^([A-Z]+-[0-9]+):?\s*(.*?)\s*(\S+)$/\2 [\1] \3/')" + + # combine doubled square brackets at the end + line="$(echo "${line}" | perl -pe 's/^\s*(.*?)\s*\[([A-Z]+-[0-9]+)\]\s*\[([^]]+)\]\s*(\S+)$/\1 [\3, \2] \4/')" + + changelog+=("- ${line}") + done <<< "${commits}" + + + # create or update comment + comment_body="$(cat <> $GITHUB_ENV + else + echo 'PR title must match format "Release: vX.Y.Z(-rc.#)?"' + exit 1 + fi + + # check that tag doesn't exist + if git ls-remote --exit-code "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}" "refs/tags/${RELEASE_TAG}"; then + echo "The PR title's version exists already" + exit 1 + fi From fabdc1ee2453927b18c9db0e24c6a4bae2cf8dcd Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Wed, 25 Aug 2021 03:10:06 +0000 Subject: [PATCH 5/8] feat(ci): add docs-site holobranch --- .holo/branches/docs-site/_codeforphilly.toml | 5 +++++ .holo/branches/docs-site/_laddr.toml | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 .holo/branches/docs-site/_codeforphilly.toml create mode 100644 .holo/branches/docs-site/_laddr.toml diff --git a/.holo/branches/docs-site/_codeforphilly.toml b/.holo/branches/docs-site/_codeforphilly.toml new file mode 100644 index 00000000..ea92412d --- /dev/null +++ b/.holo/branches/docs-site/_codeforphilly.toml @@ -0,0 +1,5 @@ +[holomapping] +files = [ + "docs/**", + "mkdocs.*.yml" +] diff --git a/.holo/branches/docs-site/_laddr.toml b/.holo/branches/docs-site/_laddr.toml new file mode 100644 index 00000000..5acc739a --- /dev/null +++ b/.holo/branches/docs-site/_laddr.toml @@ -0,0 +1,4 @@ +[holomapping] +holosource="=>docs-skeleton" +files = "**" +before = "*" From 1e75aa69bfa4cf68996bac9d04264f5ab628065f Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Wed, 25 Aug 2021 03:10:15 +0000 Subject: [PATCH 6/8] feat(docs): configure mkdocs --- mkdocs.repo.yml | 6 ++++++ mkdocs.site.yml | 7 +++++++ mkdocs.studio.yml | 6 ++++++ 3 files changed, 19 insertions(+) create mode 100644 mkdocs.repo.yml create mode 100644 mkdocs.site.yml create mode 100644 mkdocs.studio.yml diff --git a/mkdocs.repo.yml b/mkdocs.repo.yml new file mode 100644 index 00000000..d19b90d7 --- /dev/null +++ b/mkdocs.repo.yml @@ -0,0 +1,6 @@ +repo_url: https://github.com/CodeForPhilly/codeforphilly + +extra: + repository: + name: laddr + url: git@github.com:CodeForPhilly/codeforphilly.git diff --git a/mkdocs.site.yml b/mkdocs.site.yml new file mode 100644 index 00000000..4c71926a --- /dev/null +++ b/mkdocs.site.yml @@ -0,0 +1,7 @@ +site_name: CodeForPhilly.org Docs +site_url: https://codeforphilly.github.io/codeforphilly + +theme: + palette: + primary: "red" + accent: "blue" diff --git a/mkdocs.studio.yml b/mkdocs.studio.yml new file mode 100644 index 00000000..33882cb5 --- /dev/null +++ b/mkdocs.studio.yml @@ -0,0 +1,6 @@ +extra: + studio: + name: codeforphilly-studio + web_port: 9080 + docs_port: 9088 + mysql_port: 9086 From 1a38cfe9ab0b6a04179be9d9a277218edb0d1766 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Wed, 25 Aug 2021 03:13:42 +0000 Subject: [PATCH 7/8] refactor(deps): switch to tagged laddr v3.0.1 --- .holo/branches/emergence-site/_codeforphilly.toml | 13 +++++++++++-- .holo/branches/emergence-site/_laddr.toml | 3 ++- .holo/sources/laddr.toml | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.holo/branches/emergence-site/_codeforphilly.toml b/.holo/branches/emergence-site/_codeforphilly.toml index 4c3d8219..83b46b6b 100644 --- a/.holo/branches/emergence-site/_codeforphilly.toml +++ b/.holo/branches/emergence-site/_codeforphilly.toml @@ -1,7 +1,16 @@ [holomapping] files = [ "*/**", - "!cypress/**", - "!script/**", + + # exclude CI and developer assets + "!.github/", + "!.vscode/", + "!cypress/", + "!docs/", + "!fixtures/", + "!habitat/", + "!helm-chart/", + "!php-config/Git.config.d/", + "!script/", ] after = "*" diff --git a/.holo/branches/emergence-site/_laddr.toml b/.holo/branches/emergence-site/_laddr.toml index 94db1844..bbf2baa5 100644 --- a/.holo/branches/emergence-site/_laddr.toml +++ b/.holo/branches/emergence-site/_laddr.toml @@ -1,3 +1,4 @@ [holomapping] -files = "*/**" +holosource="=>emergence-skeleton" +files = "**" before = "*" diff --git a/.holo/sources/laddr.toml b/.holo/sources/laddr.toml index 3ea9bec3..e3f020fe 100644 --- a/.holo/sources/laddr.toml +++ b/.holo/sources/laddr.toml @@ -1,3 +1,3 @@ [holosource] url = "https://github.com/CodeForPhilly/laddr" -ref = "refs/heads/emergence/skeleton/v3" +ref = "refs/tags/v3.0.1" From 16ce67f3f7823cfcb81c61c89f1dfb85a4392d39 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Wed, 25 Aug 2021 03:18:58 +0000 Subject: [PATCH 8/8] fix(ci): use codeforphilly-bot user to prepare releases --- .github/workflows/release-prepare.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-prepare.yml b/.github/workflows/release-prepare.yml index 8770094c..d0f15df9 100644 --- a/.github/workflows/release-prepare.yml +++ b/.github/workflows/release-prepare.yml @@ -5,6 +5,7 @@ on: branches: [ develop ] env: + GITHUB_USERNAME: codeforphilly-bot GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} RELEASE_BRANCH: releases/v1 @@ -42,7 +43,7 @@ jobs: if [ -n "${pr_number}" ]; then echo "Updating PR #${pr_number}" - existing_comment_id=$(hub api "/repos/${GITHUB_REPOSITORY}/issues/${pr_number}/comments" | jq '.[] | select(.user.login=="jarvus-bot") | .id') + existing_comment_id=$(hub api "/repos/${GITHUB_REPOSITORY}/issues/${pr_number}/comments" | jq '.[] | select(.user.login=="${GITHUB_USERNAME}") | .id') else echo "Opening PR" hub pull-request -b "${RELEASE_BRANCH}" -h develop -F <(echo "${pr_body}") > /tmp/pr.json