Skip to content

Commit

Permalink
Merge branch 'master' into ingress-jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
brokenpip3 authored Mar 15, 2024
2 parents ad491e6 + 036b20c commit c1e2763
Show file tree
Hide file tree
Showing 26 changed files with 1,185 additions and 597 deletions.
7 changes: 7 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
"version": "latest"
},
"ghcr.io/brokenpip3/devcontainers-bats/bats-libs:0": {
},
"ghcr.io/devcontainers/features/nix:1": {
"multiUser": "false",
"extraNixConfig": "experimental-features = nix-command flakes"
},
"ghcr.io/devcontainers/features/hugo:1": {
"version": "v0.99.1"
}
},
// "forwardPorts": [],
Expand Down
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
1 change: 1 addition & 0 deletions .github/workflows/auto-tests-bats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
- 'backup/**'
- '*.md'

#TODO: create a matrix per earch bats file
jobs:
run-tests:
if: github.event.pull_request.draft == false
Expand Down
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,8 @@ chart/jenkins-operator/deploy.tmp

### Nix
result

### website
website/node_modules
website/public
website/.hugo_build.lock
8 changes: 6 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 @@ -181,6 +181,10 @@ update-lts-version: ## Update the latest lts version
sed -i 's|jenkins/jenkins:[0-9]\+.[0-9]\+.[0-9]\+|jenkins/jenkins:$(LATEST_LTS_VERSION)|g' test/e2e/test_utility.go
sed -i 's|jenkins/jenkins:[0-9]\+.[0-9]\+.[0-9]\+|jenkins/jenkins:$(LATEST_LTS_VERSION)|g' test/helm/helm_test.go
sed -i 's|jenkins/jenkins:[0-9]\+.[0-9]\+.[0-9]\+|jenkins/jenkins:$(LATEST_LTS_VERSION)|g' pkg/constants/constants.go
#TODO: source the version from config.base.env for bats test, no need of hardcoded version
sed -i 's|jenkins/jenkins:[0-9]\+.[0-9]\+.[0-9]\+|jenkins/jenkins:$(LATEST_LTS_VERSION)|g' test/bats/1-deploy.bats
sed -i 's|jenkins/jenkins:[0-9]\+.[0-9]\+.[0-9]\+|jenkins/jenkins:$(LATEST_LTS_VERSION)|g' test/bats/2-deploy-with-more-options.bats
sed -i 's|jenkins/jenkins:[0-9]\+.[0-9]\+.[0-9]\+|jenkins/jenkins:$(LATEST_LTS_VERSION)|g' test/bats/3-deploy-with-webhook.bats

.PHONY: run
run: export WATCH_NAMESPACE = $(NAMESPACE)
Expand Down Expand Up @@ -451,7 +455,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.

53 changes: 36 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,49 @@
# 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

pkgs.kind
(pkgs.bats.withLibraries (p: [
p.bats-support
p.bats-assert
p.bats-file
p.bats-detik
]))
];
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.
Loading

0 comments on commit c1e2763

Please sign in to comment.