Skip to content

Commit

Permalink
Fix website build and 0.8.x pages, move deploy to workflow and nixify…
Browse files Browse the repository at this point in the history
… the website part (#982)
  • Loading branch information
brokenpip3 authored Mar 10, 2024
1 parent cee2020 commit 4f03cef
Show file tree
Hide file tree
Showing 20 changed files with 807 additions and 540 deletions.
32 changes: 22 additions & 10 deletions .github/workflows/auto-codespell.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: codespell
name: CI Lint
on:
push:
branches:
Expand All @@ -8,14 +8,26 @@ on:
types: [opened, synchronize, ready_for_review, reopened]
jobs:
codespell:
name: codespell
name: Codespell
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/actions-codespell@v2
with:
check_filenames: true
ignore_words_list: aks,ags,startin
skip: "*.js,package-lock.json,*.lock,*/Font-Awesome/*,*.toml,*.svg,*assets/vendor/bootstrap*,cert-manager.crds.yaml"
- name: Checkout
uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/actions-codespell@v2
with:
check_filenames: true
ignore_words_list: aks,ags,startin
skip: "*.js,package-lock.json,*.lock,*/Font-Awesome/*,*.toml,*.svg,*assets/vendor/bootstrap*,cert-manager.crds.yaml"
pre-commit:
name: PreCommit
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Checkout
uses: actions/checkout@v4
- id: files
uses: tj-actions/changed-files@v42
- uses: pre-commit/[email protected]
with:
extra_args: --files ${{ steps.files.outputs.all_changed_files }} --show-diff-on-failure
121 changes: 70 additions & 51 deletions .github/workflows/auto-gen-docs.yaml
Original file line number Diff line number Diff line change
@@ -1,86 +1,105 @@
name: auto-generate-docs
name: Website

# Run this workflow every time a new commit pushed to your repository
on:
push:
branches:
- master
- main
paths:
- 'docs/**'
- 'website/**'
- 'assets/**'
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
paths:
- 'website/**'
- 'assets/**'

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "website"
cancel-in-progress: false

defaults:
run:
shell: bash

jobs:
# Set the job key. The key is displayed as the job name
# when a job name is not provided
docs:
# Name the Job
name: auto-generate-docs
# Set the type of machine to run on
update-date:
name: Auto update dates
runs-on: ubuntu-latest

if: github.event_name == 'pull_request' || (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- uses: DeterminateSystems/nix-installer-action@v9
with:
diagnostic-endpoint: ""
- uses: DeterminateSystems/magic-nix-cache-action@v3
with:
diagnostic-endpoint: ""
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive # Fetch the Docsy theme
fetch-depth: 0

# Checks if the previous commit introduced any changes to website files
- name: Check for changes
run: |
IS_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -Ec "^website*" || :)
[[ $IS_CHANGED -gt 0 ]] && echo "IS_CHANGED=true" >> $GITHUB_ENV || echo "IS_CHANGED=false" >> $GITHUB_ENV
# Sets up the appropriate version of Hugo
- name: Setup Hugo
if: env.IS_CHANGED == 'true'
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.113.0'
extended: true

# Sets up node - required by Hugo
- name: Setup Node
if: env.IS_CHANGED == 'true'
uses: actions/setup-node@v4
with:
node-version: '12.x'

# Installs dependencies required by docsy theme
- name: Install docsy dependencies
if: env.IS_CHANGED == 'true'
run: |
cd website
npm install
npm build
sudo npm install -D --save autoprefixer
sudo npm install -D --save postcss-cli
cd ../
- name: Update last modified date in modified docs
if: env.IS_CHANGED == 'true'
run: |
git diff --name-only --diff-filter=d ${{ github.event.before }} ${{ github.sha }} | grep -E "^website*" \
| sed -e 's/\(.*\)/"\1"/' | xargs sed -i "/date:/c\date: $(date +'%Y-%m-%d')"
# Runs makefile goal - checks changes to /website folder and generates docs
- name: Run Makefile goal
if: env.IS_CHANGED == 'true'
env:
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make generate-docs

# Creates pull request with generated docs
- name: Create Pull Request
if: env.IS_CHANGED == 'true'
uses: peter-evans/create-pull-request@v6
if: env.IS_CHANGED == 'true' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
with:
commit-message: Auto-updated docs
branch: docs-generator
title: Auto-generated docs update
body: |
Auto generated docs from master commit ${{ github.sha }}
website-generate:
name: Auto generate website
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
steps:
- uses: DeterminateSystems/nix-installer-action@v9
with:
diagnostic-endpoint: ""
- uses: DeterminateSystems/magic-nix-cache-action@v3
with:
diagnostic-endpoint: ""
- name: Checkout code
uses: actions/checkout@v4
- name: nix checks
run: nix flake check
- name: nix build
env:
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: nix build .#website
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./result

website-deploy:
name: Deploy website
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: website-generate
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions .github/workflows/release-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ jobs:
make helm-e2e E2E_TEST_ARGS='-ginkgo.v'
- name: Test - bats
env:
BATS_LIB_PATH: "${{ github.workspace }}/.bats"
if: ${{ github.event.inputs.skipTests != 'true' }}
run: make bats-tests

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ chart/jenkins-operator/deploy.tmp

### Nix
result

### website
website/node_modules
website/public
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ifeq ($(strip $(HAS_HELM)),)
rm -rf $(PROJECT_DIR)/bin/$(PLATFORM)-amd64
rm -rf $(PROJECT_DIR)/bin/helm.tar.gz
else
mkdir -p $(PROJECT_DIR)/bin
mkdir -p $(PROJECT_DIR)/bin
test -L $(PROJECT_DIR)/bin/helm || ln -sf $(shell command -v helm) $(PROJECT_DIR)/bin/helm
endif

Expand Down Expand Up @@ -451,7 +451,7 @@ endif

# Download and build hugo extended locally if necessary
HUGO_PATH = $(shell pwd)/bin/hugo
HUGO_VERSION = v0.113.0
HUGO_VERSION = v0.99.1
HAS_HUGO := $(shell $(HUGO_PATH)/hugo version 2>&- | grep $(HUGO_VERSION))
hugo:
ifeq ($(HAS_HUGO), )
Expand Down
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 28 additions & 17 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
flake-utils.url = "github:numtide/flake-utils";
go_15.url = "github:nixos/nixpkgs/4eccd6f731627ba5ad9915bcf600c9329a34ca78";
golangci.url = "github:nixos/nixpkgs/e912fb83d2155a393e7146da98cda0e455a80fb6";
hugo_099.url = "github:nixos/nixpkgs/d6df226c53d46821bd4773bd7ec3375f30238edb";
gomod2nix = {
url = "github:nix-community/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};

outputs = { self, nixpkgs, flake-utils, go_15, golangci, gomod2nix, ... }:
outputs = { self, nixpkgs, flake-utils, go_15, golangci, gomod2nix, hugo_099, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
go_15_pkgs = go_15.legacyPackages.${system};
golangci_pkgs = golangci.legacyPackages.${system};
hugo_099_pkgs = hugo_099.legacyPackages.${system};
operatorVersion = builtins.readFile ./VERSION.txt;
sdkVersion = ((builtins.fromTOML (builtins.readFile ./config.base.env)).OPERATOR_SDK_VERSION);
jenkinsLtsVersion = ((builtins.fromTOML (builtins.readFile ./config.base.env)).LATEST_LTS_VERSION);
Expand All @@ -30,32 +32,41 @@
# shell in nix develop
devShells.default = nixpkgs.legacyPackages.${system}.mkShell {
packages = [
pkgs.gnumake
pkgs.wget
pkgs.helm-docs
(pkgs.writeShellApplication {
name = "make_matrix";
runtimeInputs = with pkgs; [ bash gnugrep gawk ];
text = builtins.readFile ./test/make_matrix_ginkgo.sh;
})
go_15_pkgs.go
golangci_pkgs.golangci-lint
pkgs.gnumake
pkgs.wget
pkgs.helm-docs
(pkgs.writeShellApplication {
name = "make_matrix";
runtimeInputs = with pkgs; [ bash gnugrep gawk ];
text = builtins.readFile ./test/make_matrix_ginkgo.sh;
})
go_15_pkgs.go
golangci_pkgs.golangci-lint
];
shellHook = ''
echo Operator Version ${operatorVersion}
echo Latest Jenkins LTS version: ${jenkinsLtsVersion}
echo Operator SDK version: ${sdkVersion}
echo Operator Version ${operatorVersion}
echo Latest Jenkins LTS version: ${jenkinsLtsVersion}
echo Operator SDK version: ${sdkVersion}
'';
};

# nix shell .#gomod
devShells.gomod = pkgs.callPackage ./nix/shell.nix {
inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
devShells.gomod = pkgs.callPackage ./nix/gomod-shell.nix {
inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
};

# nix shell .#website
devShells.website = pkgs.callPackage ./nix/website-shell.nix {
inherit pkgs system hugo_099_pkgs;
};

# nix build with gomod2nix
packages.default = pkgs.callPackage ./nix {
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
};

packages.website = import ./nix/website-build.nix {
inherit pkgs system hugo_099_pkgs;
};

}
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions nix/website-build.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ pkgs, system, hugo_099_pkgs }:

let
buildPackages = [
hugo_099_pkgs.hugo #hugo pre-v100
pkgs.nodejs_21 #Node 1.21
pkgs.nodePackages.autoprefixer
pkgs.nodePackages.postcss
pkgs.nodePackages.postcss-cli
];
baseUrl = ((builtins.fromTOML (builtins.readFile ../website/config.toml)).baseURL);
in
pkgs.buildNpmPackage {
name = "jenkins-kubernetes-operator-website";
src = ../website;
version = "0.0.1";
npmDepsHash = "sha256-NcspVYF+9dCrGxH/cGNhD+TxLZm6ZDX523mKm9smAAA=";
nativeBuildInputs = buildPackages;
buildPhase = "npm run build";
installPhase = "cp -r public $out";
}
17 changes: 17 additions & 0 deletions nix/website-shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ pkgs, system, hugo_099_pkgs }:

let
devShellPackages = [
hugo_099_pkgs.hugo #hugo pre-v100
pkgs.nodejs_21 #Node 1.21
];
baseUrl = ((builtins.fromTOML (builtins.readFile ../website/config.toml)).baseURL);
in
pkgs.mkShell {
packages = devShellPackages;
shellHook = ''
npm install --save-dev
npm list
'';
BASE_URL = "${baseUrl}";
}
1 change: 1 addition & 0 deletions website/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
has nix && use flake ../.#website
Loading

0 comments on commit 4f03cef

Please sign in to comment.