From ab5fb7e17dfae33384815dc6d27a1ce68b70044f Mon Sep 17 00:00:00 2001 From: Yusuke Tsutsumi Date: Fri, 1 Nov 2024 10:38:05 -0700 Subject: [PATCH] chore: update tests to use site-generator-beta (#235) the site-generator-beta is the new aep website. Use that in CI instead of the old one. --- .github/workflows/publish.yaml | 27 ------------- .github/workflows/test.yaml | 8 ++-- CONTRIBUTING.md | 72 ++++------------------------------ Dockerfile | 23 ----------- requirements.txt | 1 - scripts/build.sh | 18 +++++++++ scripts/serve.sh | 4 ++ serve.sh | 38 ------------------ 8 files changed, 32 insertions(+), 159 deletions(-) delete mode 100644 .github/workflows/publish.yaml delete mode 100644 Dockerfile delete mode 100644 requirements.txt create mode 100755 scripts/build.sh create mode 100755 scripts/serve.sh delete mode 100755 serve.sh diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index d3652023..00000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,27 +0,0 @@ ---- -name: publish -on: - push: - branches: - - main -# Recommended by https://github.com/JamesIves/github-pages-deploy-action -permissions: - contents: write -jobs: - github-pages: - runs-on: ubuntu-latest - container: python:3.8 - steps: - - uses: actions/checkout@v3 - - name: Install system dependencies. - run: apt-get update && apt-get install -y rsync - - name: Install the site generator. - run: pip install -r requirements.txt - - name: Build the static site. - run: aep-site-gen . out - - name: Publish the static site to GitHub Pages. - uses: jamesives/github-pages-deploy-action@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: gh-pages - folder: out diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c9d075be..804d5b9c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,10 +7,8 @@ on: jobs: build: runs-on: ubuntu-latest - container: python:3.8 + container: node:20 steps: - uses: actions/checkout@v3 - - name: Install the site-generator - run: pip install -r requirements.txt - - name: Build the site. - run: aep-site-gen . /out + - name: Generate all static pages, and build site. + run: ./scripts/build.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7db3e294..700bad62 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,76 +42,18 @@ Some tips: ## Development Environment If you are contributing AEP content (rather than code) and want to be able to -view it in your browser, the easiest way to do so is to run the provided -development server. +view it in your browser, the easiest way to do so is to run the site-generator +script. We use [GitHub Pages][1] to make this documentation available, and a specific [site generator][2] to build the site. -If you have [Docker][3] installed, clone this repository and run the `serve.sh` -file at the root of the repository. This script does two things: +Run `./scripts/serve.sh` to: -- It builds the provided Docker image (unless you already have it) and tags it - as `aep-site`. -- It runs the `aep-site` image. - -The development server uses port 4000; point your web browser to -`http://localhost:4000`, and you should see the site. - -**Note:** After building the Docker image for the first time, you may -experience issues if Python dependencies change underneath you. If this -happens, remove your Docker image (`docker rmi aep-site`) and run `serve.sh` -again. - -### Arguments - -Any arguments provided to `serve.sh` (or `docker run`) are forwarded (however, -the current site generator does not honor any; this may change in the future). +- clone the site-generator repository. +- run the appropriate npm commands. +- begin the dev server at port 4321. ### Hot reloading -The development server recognizes when files change (including static files) -and local changes will be automatically reflected in your browser upon reload. - -### Local Installation - -It is possible to run the development server locally also. The general gist of -how to do so correctly is: - -- Install Python 3.8 if you do not already have it (direct install is fine, but - [pyenv][5] is probably the best way if you have other Python projects). -- Create a Python 3.8 [venv][6]. Once it is created, activate it in your shell - (`source path/to/venv/bin/activate`). -- `pip install git+https://github.com/aep-dev/site-generator.git` -- `aep-site-serve .` - -## Contributor License Agreement - -Signing a Contributor License Agreement (CLA) is not required at this time. - -## Code reviews - -All submissions, including submissions by project members, require review. We -use GitHub pull requests for this purpose. Consult -[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more -information on using pull requests. - -### Formatting - -We use [prettier][4] to format Markdown, JavaScript, and (most) HTML, in order -to ensure a consistent style throughout our source. You can add prettier as a -plugin in most development environments. - -Once it is installed, you can fix formatting by running the following in the -root aep.dev directory: - -```sh -prettier -w . -``` - -[1]: https://pages.github.com/ -[2]: https://github.com/aep-dev/site-generator -[3]: https://docker.com/ -[4]: https://prettier.io/ -[5]: https://github.com/pyenv/pyenv -[6]: https://docs.python.org/3/library/venv.html +The development server currently does not support hot reloading. diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index dfa08f97..00000000 --- a/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM python:3.8-alpine - -# Define the working directory. -# Note: There is no code here; it is pulled from the repository by mounting -# the directory (see `serve.sh`). -WORKDIR /code/ - -# Install Python packages for this project. -COPY requirements.txt /code/requirements.txt -RUN apk add git && \ - pip install -r requirements.txt && \ - apk del git - -# Set environment variables. -ENV FLASK_ENV development - -# Expose appropriate ports. -EXPOSE 4000 -EXPOSE 35729 - -# Run the development server. -# Reminder: Use -p with `docker run` to publish ports (see `serve.sh`). -ENTRYPOINT ["aep-site-serve", "."] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index aadfff46..00000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -aep-site-generator==0.9.2 diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 00000000..97c4f356 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -x +export AEP_LOCATION="${PWD}" +export SG_DIRECTORY="/tmp/site-generator-beta" +export AEP_LINTER_LOC="${SG_DIRECTORY}/api-linter" +if [ ! -d "${SG_DIRECTORY}" ]; then + git clone https://github.com/aep-dev/site-generator-beta.git "${SG_DIRECTORY}" +fi + +if [ ! -d "${AEP_LINTER_LOC}" ]; then + git clone https://github.com/aep-dev/api-linter.git "${AEP_LINTER_LOC}" +fi +cd "${SG_DIRECTORY}" || exit +# make rules / website folder +mkdir -p src/content/docs/tooling/linter/rules +mkdir -p src/content/docs/tooling/website +npm install +npm run generate \ No newline at end of file diff --git a/scripts/serve.sh b/scripts/serve.sh new file mode 100755 index 00000000..d34b5665 --- /dev/null +++ b/scripts/serve.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -x +. ./scripts/build.sh +npm run preview \ No newline at end of file diff --git a/serve.sh b/serve.sh deleted file mode 100755 index bd732892..00000000 --- a/serve.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# ----------------------------------------------------------------------------- -# This script runs a "development server" from Docker. -# ----------------------------------------------------------------------------- - -# capture the first argument as the port, defaulting to 4000 -PORT=${1:-4000} -shift - -# Build the image (if and only if it is not already built). -if [[ "$(docker images -q aep-site 2> /dev/null)" == "" ]]; then - docker build -t aep-site . - if [ $? != 0 ]; then - exit $? - fi -fi - -# Run the image. -docker run --rm \ - -p "${PORT}:4000/tcp" -p "${PORT}:4000/udp" \ - -p 35729:35729/tcp -p 35729:35729/udp \ - --mount "type=bind,source=$(pwd),destination=/code/,readonly" \ - aep-site \ - "$@"