Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
c6a82ec
testing container build
elreydetoda Sep 3, 2022
db290fa
- trying to fix e2e tests
elreydetoda Aug 29, 2022
72bb220
adding GH action to build containers & docs
elreydetoda Sep 3, 2022
4fd99db
Dockerfile.tests use official playwright container
elreydetoda Sep 3, 2022
79f1fa0
- trying to re-use built containers for tests
elreydetoda Sep 3, 2022
fa8bc0d
fixing error in e2e.yml
elreydetoda Sep 4, 2022
5158ba1
running container as service inside of GH actionj
elreydetoda Sep 4, 2022
ddce00c
changing build process for prodo container, and building test's web c…
elreydetoda Sep 5, 2022
80033b4
fixing failing test with api call instead of page
elreydetoda Sep 5, 2022
b7b9be2
swapping around containers on e2e tests
elreydetoda Sep 5, 2022
4ed5bef
simplifying GH action with matrix
elreydetoda Sep 5, 2022
094022e
changing name back to e2e-tests
elreydetoda Sep 5, 2022
8384c9d
adding development dependencies
elreydetoda Sep 5, 2022
369d051
- running e2e tests after prod re-build
elreydetoda Sep 5, 2022
59e6a2c
modifying image building + tagging for GH matrix
elreydetoda Sep 5, 2022
62510b1
disabling E2E on PRs & pushes
elreydetoda Sep 5, 2022
fc895f9
- re-ordering test_dropdowns
elreydetoda Sep 6, 2022
357d413
- too many permissions issues
elreydetoda Sep 6, 2022
0a16f46
adding docker-compose for testing
elreydetoda Sep 6, 2022
277ef9f
adding hack for no tty
elreydetoda Sep 6, 2022
5fda0fc
wrong path...
elreydetoda Sep 6, 2022
9a74088
adding comment on why using docker-compose
elreydetoda Sep 6, 2022
6f88ab9
testing building with buildkit for time of build
elreydetoda Sep 6, 2022
7d545c7
commenting on where environment variables are from
elreydetoda Sep 6, 2022
720f250
excluding report upload during PRs, don't have permissions to do so
elreydetoda Sep 7, 2022
eedb4e3
- documenting everything
elreydetoda Sep 8, 2022
16d2a5a
slightly tweaking container build steps
elreydetoda Sep 8, 2022
3aae88f
only need to re-build on pushes to main currently
elreydetoda Sep 8, 2022
3b2af68
fixing test that's currently failing in prod
elreydetoda Sep 9, 2022
5695477
Merge branch 'main' into patch/modifying_e2e_GH_action
elreydetoda Sep 9, 2022
1f835f9
adding develop support
elreydetoda Sep 13, 2022
924fd2c
Merge pull request #12 from elreydetoda/patch/modifying_e2e_GH_action
elreydetoda Sep 13, 2022
4e0f7b5
changing variable for container's to build for tag
elreydetoda Sep 13, 2022
402fd4f
fixing env var referencing branch name
elreydetoda Sep 13, 2022
28bf5bf
Merge branch 'develop' into patch/modifying_e2e_GH_action
elreydetoda Sep 14, 2022
109fb64
modifying well known to support #420
elreydetoda Sep 14, 2022
b1042e6
Build sponsor list from episodes
ChanceM Sep 16, 2022
e9e4a78
Merge branch 'develop' into patch/modifying_e2e_GH_action
elreydetoda Sep 27, 2022
9929712
adding development mark (tag) for easy testing of single tests
elreydetoda Sep 29, 2022
bb5fe8d
fixing breaking test by being more specific for navbar links
elreydetoda Sep 29, 2022
f69cb66
Set Sponsor lookback to 3mo (90d)
ChanceM Oct 8, 2022
4f12aaf
Merge branch 'JupiterBroadcasting:develop' into feature/automate-spon…
ChanceM Oct 8, 2022
40c9e52
Merge branch 'feature/automate-sponsors-page' of github.com:ChanceM/j…
ChanceM Oct 8, 2022
5760ea8
adding netlify config
elreydetoda Aug 19, 2022
3d107e1
updating readme to not the places hugo version needs updating
elreydetoda Aug 19, 2022
d165b7b
enabling cool config functionality
elreydetoda Aug 19, 2022
3d10fdc
trying to fix #319
elreydetoda Aug 19, 2022
ad44b0e
fixed URL encoding going to wrong page
elreydetoda Oct 9, 2022
2cdd138
adding render.yml config file instead of netlify
elreydetoda Oct 9, 2022
505a343
renaming so render will see file... 🤦
elreydetoda Oct 9, 2022
b07aefa
adding missing key
elreydetoda Oct 9, 2022
d80f5e3
specifying plan type
elreydetoda Oct 9, 2022
1d05919
changing to starter because got error on free...
elreydetoda Oct 9, 2022
45191b2
removing netlify.toml config reference in readme
elreydetoda Oct 9, 2022
cefc682
Make requested changes to sponsor generation
ChanceM Oct 10, 2022
d822883
Add JB Network Wide Sponsors
ChanceM Oct 11, 2022
4625037
Add comment on when regex can be removed
ChanceM Oct 11, 2022
e9de61d
🙈 Add fleet folder to gitignore
CGBassPlayer Oct 15, 2022
207ea49
Append manual show sponsors via shows _index.md.
ChanceM Oct 15, 2022
7e3c6de
Merge branch 'develop' into feature/automate-sponsors-page
ChanceM Oct 15, 2022
8c39427
Merge pull request #462 from CGBassPlayer/feature/fleet-ignore
elreydetoda Oct 16, 2022
83b6c0b
This increases the heading size of topic in footer
Oct 17, 2022
979fa1e
Another attempt at increasing the size of footer
Oct 17, 2022
748bd22
Merge pull request #464 from BenjaminHCCarr/jb-footer-bigger
elreydetoda Oct 18, 2022
80ee032
Remove line length limit.
ChanceM Oct 23, 2022
41ba3a4
Merge branch 'feature/automate-sponsors-page' of github.com:ChanceM/j…
ChanceM Oct 23, 2022
e97e765
removing unintended side effect from
elreydetoda Oct 23, 2022
d4d5026
Merge pull request #456 from elreydetoda/feat/netlify_config/257
gerbrent Oct 23, 2022
7a3a824
Move sponsor pages to variable.
ChanceM Oct 23, 2022
64b099d
small comment about keeping python version in sync
elreydetoda Oct 23, 2022
2c80d46
Merge pull request #353 from elreydetoda/patch/modifying_e2e_GH_action
gerbrent Oct 23, 2022
73a95de
add `develop` default branch, deploy previews
gerbrent Oct 23, 2022
e9fa5ea
update deploy preview link to be relative
gerbrent Oct 23, 2022
9984e6c
Merge pull request #451 from ChanceM/feature/automate-sponsors-page
elreydetoda Oct 25, 2022
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
10 changes: 9 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@ public/
.github/
.git/
fireside-scraper
scraped-data
scraped-data
# ignoring when dockerfiles themselves
Dockerfile*
# ignoring all of tests directory
# container only needs dependencies, and tests are run during it's execution
test/
# allowing Pipfiles, since used in Dockerfile.tests
!/test/Pipfile
!/test/Pipfile.lock
92 changes: 92 additions & 0 deletions .github/workflows/build_container-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Building Prod Container

# built with the following guides/examples:
# - https://github.com/marketplace/actions/push-to-registry#examples
# - https://github.com/marketplace/actions/buildah-build#building-using-containerfiles

on:
push:
branches:
- main
- develop
# don't re-build prod when there's only test changes
paths-ignore:
- ./Dockerfile.tests
- "./tests/**"

workflow_dispatch:

workflow_run:
workflows: ["Scrape and commit"]
types:
- completed

jobs:
# this sets up some variables so the next job can use them for tags
env_setup:
runs-on: ubuntu-latest
outputs:
date_output: ${{ steps.date.outputs.date_fmt }}
registry_user: ${{ steps.registry_user.outputs.username }}
current_branch: ${{ steps.current_branch.outputs.current_branch }}
steps:
# used for tagging the container with the current date down to the seconds
# since we have so many changes down to the seconds was required. Example: 2022-09-08T05_42_23-04_00
- id: date
run: echo "::set-output name=date_fmt::$(date -Isec | tr ':' '_' | tr '+' '-' )"
# the username for the quay registry, since it can be derived from the quay secret's robot username
- id: registry_user
run: echo "::set-output name=username::$(cut -d '+' -f 1 <<< ${{ secrets.REGISTRY_USER }})"
- id: current_branch
run: echo "::set-output name=current_branch::$( [ "${GITHUB_REF_NAME}" != "main" ] && echo "-${GITHUB_REF_NAME:-}" )"

prod:
strategy:
# this causes containers to be built at the same time
matrix:
# these 2 containers are being built seperately because they need to have different --baseURL parameters
container_env:
# the tests_web one needs to have --baseURL='/', this allows the tests to run from any domain and allows
# it to be relative off of that domain. i.e. http://jb.io is the base domain, and they'll all be off of it's root path
- 'TESTS_WEB'
# this is the normal production site being built and versioned
- 'PROD'
runs-on: ubuntu-latest
# requires the previous job to complete before attempting to run this job
needs: env_setup
# location where the credentials are stored for quay
environment: production_containers
steps:
- uses: actions/checkout@v2

- name: Building container image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: jb_web_container
# tagging with 2 different tags, this will let us have a consistent target of prod-latest or tests_web-latest,
# but still allow us to properly version each build of the containers (with the current time). This double
# tagging strategy will allow us to rollback changes on the prod environment if something goes awry
# example location as to where to change that in prod's ansible IaC
# https://github.com/JupiterBroadcasting/infra/blob/3b9490a46119ffdc70018b2ac8315346d947a06d/ansible/group_vars/core.yaml#L517
# tag example: prod-latest, prod-develop-latest, prod-develop-2022-09-12t23_15_22-04_00, or prod-2022-09-12t23_15_22-04_00
tags: ${{ matrix.container_env }}${{ needs.env_setup.outputs.current_branch }}-latest ${{ matrix.container_env }}${{ needs.env_setup.outputs.current_branch }}-${{ needs.env_setup.outputs.date_output }}
# prod docker container docker file
containerfiles: |
./Dockerfile
# changes the build base URL based on the name passed into this build arguement
build-args: |
BASE_URL=${{ matrix.container_env }}

- name: Push To quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: quay.io/${{ needs.env_setup.outputs.registry_user }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
67 changes: 67 additions & 0 deletions .github/workflows/build_container-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Building Tests Container

# built with the following guides/examples:
# - https://github.com/marketplace/actions/push-to-registry#examples
# - https://github.com/marketplace/actions/buildah-build#building-using-containerfiles

on:
push:
branches:
- main
- develop
paths:
- ./Dockerfile.tests
- ./tests/Pipfile.lock

workflow_dispatch:

jobs:
# this sets up some variables so the next job can use them for tags
env_setup:
runs-on: ubuntu-latest
outputs:
date_output: ${{ steps.date.outputs.date_fmt }}
registry_user: ${{ steps.registry_user.outputs.username }}
current_branch: ${{ steps.current_branch.outputs.current_branch }}
steps:
# used for tagging the container with the current date down to the seconds
# since we have so many changes down to the seconds was required. Example: 2022-09-08T05_42_23-04_00
- id: date
run: echo "::set-output name=date_fmt::$(date -Isec | tr ':' '_' | tr '+' '-' )"
# the username for the quay registry, since it can be derived from the quay secret's robot username
- id: registry_user
run: echo "::set-output name=username::$(cut -d '+' -f 1 <<< ${{ secrets.REGISTRY_USER }})"
- id: current_branch
run: echo "::set-output name=current_branch::$( [ "${GITHUB_REF_NAME}" != "main" ] && echo "-${GITHUB_REF_NAME:-}" )"

tests:
runs-on: ubuntu-latest
needs: env_setup
# location where the credentials are stored for quay
environment: production_containers
steps:
- uses: actions/checkout@v2
- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: jb_web_container
# tagging with 2 different tags, this will let us have a consistent target of prod-latest or tests_web-latest,
# but still allow us to properly version each build of the containers (with the current time). This double
# tagging strategy will allow us to rollback changes on the prod environment if something goes awry
tags: tests${{ needs.env_setup.outputs.current_branch }}-latest tests${{ needs.env_setup.outputs.current_branch }}-${{ needs.env_setup.outputs.date_output }}
containerfiles: |
./Dockerfile.tests

- name: Push To quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: quay.io/${{ needs.env_setup.outputs.registry_user }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
30 changes: 30 additions & 0 deletions .github/workflows/build_containers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Containers Docs

This is the documentation for how the build_container-*.yml files works, and the needed permissions/setup around it.

## Registry

We're using quay.io for the container registry, reasons why are outlined in [this comment](https://github.com/JupiterBroadcasting/jupiterbroadcasting.com/issues/244#issuecomment-1213146790)

## Authentication to registry

1. Naviage to: <https://quay.io/signin/>
2. Create a Red Hat account if you don't have one, or sign in
3. Navigate to the following (be sure to replace `<username>` with your quay.io username): `https://quay.io/user/<username>?tab=repos`
4. Click "Create New Repository" (near the top right)
5. Give the repo a name (this will be the name of you container) i.e. jb_web_container
6. Make sure you've selected the Repository Visibility as Public and you're going to be choosing "(Empty repository)" for the Initialize repository section
7. Navigate to the following (be sure to replace `<username>` with your quay.io username): `https://quay.io/user/<username>?tab=robots`
8. Click "Create Robot Account"
9. Give the robot a name (i.e. `jb_web_container`), and a description
10. find the repo you just created, and select the dropdown that says "None"
11. Choose the "Write" permission
12. Click "Add permissions"
13. Click on the gear on the far right side of the screen for your new robot account
14. Click "View Credentials"
15. Create an environment variables based on [this guide](https://blog.elreydetoda.site/github-action-security/), and have the environment name called production_containers.
16. Click "Add Secret" under Environment secrets, and add the following secrets
* `REGISTRY_PASSWORD` = your robot account token (long string of random characters)
17. Then go to this link (replace `GH_user_name` with your GitHub username): `https://github.com/jupiterbroadcasting/jupiterbroadcasting.com/settings/secrets/actions/new`, to create a repo secret
* `REGISTRY_USER` = your robot account username
* This isn't necessarily that sensative, so creating a repo secret instead of an environment secret is ok
3 changes: 2 additions & 1 deletion .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ on:
# scraper will run and not commit anything, but after #215 is solved
# then it should only run after castablasta pushes a new episode
workflow_run:
workflows: ["Scrape and commit"]
# putting the comment here to enable prod changes in the future to leverage the created containers
workflows: ["Scrape and commit"] #, "Building Prod Container"]
types:
- completed

Expand Down
53 changes: 24 additions & 29 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
name: E2E Tests

on:
# keeping this till we figure out #371, so we can at least validate the
# scrapper PRs aren't breaking things
push:
branches: [ main ]

# https://frontside.com/blog/2020-05-26-github-actions-pull_request/
pull_request:

push:
branches:
- main
- develop
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand All @@ -18,36 +16,33 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: run hugo build
uses: jakejarvis/hugo-build-action@master
with:
args: --gc --config ./config.toml -b http://localhost:1313
- name: run server
run: |
cd public && python -m http.server 1313 &
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
working-directory: ./test
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Ensure browsers are installed
run: python -m playwright install --with-deps

# using docker-compose, so we can re-use local Dockerfiles
- name: starting up containers
working-directory: ./test/
env:
# https://stackoverflow.com/a/52192327
DOCKER_BUILDKIT: 1
# https://stackoverflow.com/a/69500575
BUILDKIT_PROGRESS: plain
run: docker-compose up -d --build

- name: Run your tests
working-directory: ./test
run: pytest --base-url http://localhost:1313 -v --junitxml report.xml e2e/*
working-directory: ./test/
# https://github.com/actions/runner/issues/241#issuecomment-577360161
run: script -e -c "docker-compose exec testing pytest --base-url http://jb-com --junitxml report.xml"

- name: Save screenshots
uses: actions/upload-artifact@v2
with:
name: screenshots
path: test/screenshots/
path: screenshots/

- name: Publish Test Report
uses: dorny/test-reporter@v1
if: always()
# TODO: potential solution in the future: https://stackoverflow.com/a/70448851
if: always() && github.event_name != 'pull_request'
with:
name: E2E Tests
path: './test/report.xml'
path: './report.xml'
reporter: java-junit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ $RECYCLE.BIN/
.vscode
.kateproject
.kateproject.local
.fleet


# Ignore all the scraped data
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Our base of operations for group discussions on this project is our Matrix chat
* ✅ Create a markdown checklist to indicate what's done and what's still missing ([see this example](https://github.com/JupiterBroadcasting/jupiterbroadcasting.com/pull/112)).
* ⚙ If you are closing a specific issue we encourage you to use [Github's closing keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) to automatically close the issue once the PR is merged.
* 🚮 Feel free to delete your feature branch after it has been merged via the PR. There’s a handy button on the GitHub interface, and in the worst case they can be reverted easily.
* 🎯 We currently use a `develop` branch as our default, so expect your PRs to target `develop` and not the otherwise standard `main` branch
* 🚀 We've also integrate PR deploy previews for the current `develop` branch - see the Environment section of the repo's main page sidebar. All PRs also get their own unique deploy previews found as a comment under the respective PR.


### What is the stack used for the site?
Expand Down
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
FROM registry.gitlab.com/pages/hugo/hugo_extended:0.101.0 as builder
# this defaults to an empty variable
ARG BASE_URL
WORKDIR /site
COPY . /site
RUN hugo
# when the argument is empty or PROD, do a normal production build
# else if it's TESTS_WEB use the specified baseURL "/", or
# exit 1, because that use case hasn't been provided
# https://explainshell.com/ is an awesome website which can explain this in more detail
# set -x : changes the shell's default verbosity and puts it in "debug" mode
RUN set -x && ( [ -z "${BASE_URL}" ] || [ "${BASE_URL}" == "PROD" ] ) \
&& hugo --gc \
|| ( [ "${BASE_URL}" == 'TESTS_WEB' ] && hugo --gc --baseURL "/" || exit 1 )

FROM nginx:alpine
RUN rm -rf /usr/share/nginx/html/*
Expand Down
19 changes: 6 additions & 13 deletions Dockerfile.tests
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
ARG PY_VERSION=3.10

FROM docker.io/python:${PY_VERSION}
# using v1.25.2-jammy because it's the only version which has
# python3.10, and is latest version (python verison pinned in the test/Pipfile as well (make sure to change there as well))
FROM mcr.microsoft.com/playwright/python:v1.25.2-jammy

RUN pip install pipenv

CMD [ "--base-url", "http://localhost:1313" ]
ENTRYPOINT [ "pytest" ]

RUN adduser --disabled-login --disabled-password \
--gecos '' --uid 1000 pytest
COPY test/Pipfile test/Pipfile.lock ./
RUN pipenv --bare sync --system \
&& playwright install-deps \
&& rm -rf /var/lib/apt/lists/*
# since the previous command (playwright install-deps) runs an apt-get update

USER pytest

RUN playwright install
# installing depenencies to the container's system,
# so we don't have to worry about venvs
RUN pipenv --bare sync --system
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ deploy-prod:

tests:
docker build --rm -f Dockerfile.tests -t jb_tests:latest .
docker run --rm --net=host --volume "$${PWD}":/app -w /app jb_tests:latest
docker run --rm --net=host --user 1000:1000 --volume "$${PWD}":/app -w /app jb_tests:latest
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ Deployment is done with Github Actions, see workflow file in `.github/workflows/
At the moment it is only triggered when something in the `main` branch is changing, but it can also be set up to run at certain times.
This would also enable scheduled publishing, since Hugo per default only builds pages which have set `date` in frontmatter to <= `now`

When upgrading the hugo version these are the locations whicht it needs to be updated at:

* `Dockerfile`
* `Dockerfile.dev`

Currently we're at hugo version `0.101.0`

### Credits

- Parts of the functionality are from the Castanet Theme: https://github.com/mattstratton/castanet
Expand Down
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
baseURL = 'https://www.jupiterbroadcasting.com/'
languageCode = 'en-us'
title = 'Jupiter Broadcasting'
# enableGitInfo = true

theme = 'jb'

Expand All @@ -19,7 +20,6 @@ paginate = 12
[params.footer.right]
headline = "Get Involved"


# Allow HTML in Markdown
[markup]
[markup.goldmark]
Expand Down
3 changes: 3 additions & 0 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ calendar.embedd= "jalb5frk4cunnaedbfemuqbhv4@group.calendar.google.com"
analytics = "https://plausible.ktz.cloud/js/plausible.js"

github_repo = "https://github.com/JupiterBroadcasting/jupiterbroadcasting.com"

# Sponsor Page
sponsors.lookbackdays = -90
Loading