Skip to content

Commit

Permalink
Split CI into multiple workflows, condense labeler
Browse files Browse the repository at this point in the history
  • Loading branch information
errose28 committed Feb 7, 2024
1 parent 1480962 commit 0533e0c
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 140 deletions.
112 changes: 6 additions & 106 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,112 +26,12 @@ concurrency:
group: ci-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
script_dir: .github/scripts
node_version: 20

# TODO add docker image caching with docker save/docker load and https://github.com/actions/cache
# Key should be a hash of Dockerfile and pnpm-lock.yaml

# TODO is additional npm caching needed on top of the setup-node action?

jobs:
static:
uses: ./.github/workflows/static.yml
build-image:
needs:
- static
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Build Docker image
run: |
docker compose build
build-website:
needs:
- build-image
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Build website
run: |
docker compose run site pnpm build
- name: Save website build artifact
uses: actions/upload-artifact@v4
with:
name: build
path: build
if-no-files-found: error
check-sitemap:
needs:
- build-website
runs-on: ubuntu-latest
steps:
- name: Get URL check script
uses: actions/checkout@v4
- name: Download website build artifact
uses: actions/download-artifact@v4
with:
name: build
path: build
- name: Check sitemap.xml
working-directory: ${{ env.script_dir }}
run: |
./url.sh "$GITHUB_WORKSPACE"/build/sitemap.xml
run-website:
needs:
- build-website
runs-on: ubuntu-latest
steps:
- name: Get Docker files
uses: actions/checkout@v4
- name: Download website build artifact
uses: actions/download-artifact@v4
with:
name: build
path: build
- name: Curl website homepage
timeout-minutes: 5
run: |
docker compose run --detach --service-ports site pnpm serve
while [ "$(curl -so /dev/null -w '%{http_code}' http://localhost:3000)" != 200 ]; do
sleep 1;
done
echo 'Website homepage is responsive.'
publish-website:
if: ${{ github.event == 'push' && github.ref_name == 'HDDS-9225-website-v2' }}
needs:
- run-website
- check-sitemap
runs-on: ubuntu-latest
steps:
- name: Download website build artifact
uses: actions/download-artifact@v4
with:
name: build
path: build
- name: "Checkout publish branch"
uses: actions/checkout@v4
with:
path: 'publish'
# Update this to asf-site when the website is ready to be published.
ref: 'asf-site-v2'
- name: "Commit changes"
working-directory: 'publish'
run: |
# Delete previous build from the branch, but preserve files with necessary metadata.
mv README.md .asf.yaml .git /tmp
rm -rf $(ls -A)
mv /tmp/README.md /tmp/.asf.yaml /tmp/.git .
# Commit new build to the branch.
cp -R ../build/. .
git config --global user.name 'Github Actions'
git config --global user.email 'noreply@github.com'
git add .
git commit -a -m "[auto] Apply changes from $GITHUB_REF_NAME $GITHUB_SHA" || true
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docusuaurus:
# needs: static
uses: ./.github/workflows/docusaurus.yml
publish:
needs: docusaurus
uses: ./.github/workflows/publish.yml
91 changes: 91 additions & 0 deletions .github/workflows/docusaurus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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
#
# http://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.

name: docusaurus

on:
workflow_call:

concurrency:
group: docusaurus-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
script_dir: .github/scripts

# TODO add docker image caching with docker save/docker load and https://github.com/actions/cache
# Key should be a hash of Dockerfile and pnpm-lock.yaml

jobs:
build-image:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Build Docker image
run: |
docker compose build
build-website:
needs:
- build-image
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Build website
run: |
docker compose run site pnpm build
- name: Save website build artifact
uses: actions/upload-artifact@v4
with:
name: build
path: build
if-no-files-found: error
check-sitemap:
needs:
- build-website
runs-on: ubuntu-latest
steps:
- name: Get URL check script
uses: actions/checkout@v4
- name: Download website build artifact
uses: actions/download-artifact@v4
with:
name: build
path: build
- name: Check sitemap.xml
working-directory: ${{ env.script_dir }}
run: |
./url.sh "$GITHUB_WORKSPACE"/build/sitemap.xml
run-website:
needs:
- build-website
runs-on: ubuntu-latest
steps:
- name: Get Docker files
uses: actions/checkout@v4
- name: Download website build artifact
uses: actions/download-artifact@v4
with:
name: build
path: build
- name: Curl website homepage
timeout-minutes: 5
run: |
docker compose run --detach --service-ports site pnpm serve
while [ "$(curl -so /dev/null -w '%{http_code}' http://localhost:3000)" != 200 ]; do
sleep 1;
done
echo 'Website homepage is responsive.'
29 changes: 0 additions & 29 deletions .github/workflows/label-pr.yml

This file was deleted.

63 changes: 63 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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
#
# http://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.

name: publish

on:
workflow_call:

concurrency:
group: publish-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

# TODO add docker image caching with docker save/docker load and https://github.com/actions/cache
# Key should be a hash of Dockerfile and pnpm-lock.yaml

jobs:
publish-website:
# if: ${{ github.event == 'push' && github.ref_name == 'HDDS-9225-website-v2' }}
needs:
- run-website
- check-sitemap
runs-on: ubuntu-latest
steps:
- name: Download website build artifact
uses: actions/download-artifact@v4
with:
name: build
path: build
- name: "Checkout publish branch"
uses: actions/checkout@v4
with:
path: 'publish'
# Update this to asf-site when the website is ready to be published.
ref: 'asf-site-v2-test'
- name: "Commit changes"
working-directory: 'publish'
run: |
# Delete previous build from the branch, but preserve files with necessary metadata.
mv README.md .asf.yaml .git /tmp
rm -rf $(ls -A)
mv /tmp/README.md /tmp/.asf.yaml /tmp/.git .
# Commit new build to the branch.
cp -R ../build/. .
git config --global user.name 'Github Actions'
git config --global user.email 'noreply@github.com'
git add .
git commit -a -m "[auto] Apply changes from $GITHUB_REF_NAME $GITHUB_SHA" || true
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 10 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ on:
- opened
- edited
- synchronize
- pull_request_target

jobs:
title:
Expand All @@ -34,4 +35,12 @@ jobs:
TITLE: ${{ github.event.pull_request.title }}
run:
.github/scripts/pr_title_check.sh "${TITLE}"

# This job reads its configuration from the .github/labeler.yml file.
# This job and its configuration can be deleted once the website's feature branch is merged.
labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
5 changes: 1 addition & 4 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ env:
script_dir: .github/scripts
node_version: 20

# TODO add docker image caching with docker save/docker load and https://github.com/actions/cache
# Key should be a hash of Dockerfile and pnpm-lock.yaml

# TODO is additional npm caching needed on top of the setup-node action?

jobs:
Expand Down Expand Up @@ -121,4 +118,4 @@ jobs:
- name: Run file name check
working-directory: ${{ env.script_dir }}
run: |
./names.sh
./names.sh

0 comments on commit 0533e0c

Please sign in to comment.