Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support all Kubernetes versions 1.20 through 1.30 #107

Merged
merged 5 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
106 changes: 77 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,109 @@ on: [push]
name: CI
jobs:
cabal:
name: Cabal / GHC ${{ matrix.ghc }}
name: Cabal / K8S ${{ matrix.k8s_release }} / GHC ${{ matrix.ghc }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
# This full matrix at time of writing is 11 K8S versions * 6 compiler versions = 66,
# which is a little big for CI.
# Commented some older versions of each to make it manageable.
matrix:
k8s_release:
# - "1.20"
# - "1.21"
# - "1.22"
# - "1.23"
# - "1.24"
- "1.25"
- "1.26"
- "1.27"
- "1.28"
- "1.29"
- "1.30"
ghc:
- "8.10.7"
- "9.0.2"
- "9.2.8"
- "9.4.5"
# - "8.10.7"
# - "9.0.2"
# - "9.2.8"
- "9.4.8"
- "9.6.5"
- "9.8.2"
steps:
- uses: actions/checkout@v3
- uses: haskell/actions/setup@v2
- uses: actions/checkout@v4

- uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: '3.8.1.0'
- run: cabal build all --enable-tests
- run: cabal test all
ghc-version: ${{ matrix.compiler.ghc }}
cabal-version: '3.10.3.0'

- uses: cachix/install-nix-action@v27

- run: |
nix run .#set-cabal-version -- "${{matrix.k8s_release}}" cabal.project
cabal build all --enable-tests

- run: |
cabal test all

stack:
name: Stack / GHC ${{ matrix.ghc }}
name: Stack / K8S ${{ matrix.k8s_release }} / GHC ${{ matrix.compiler.ghc }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
# This full matrix at time of writing is 11 K8S versions * 7 compiler versions = 77,
# which is a little big for CI.
# Commented some older versions of each to make it manageable.
matrix:
include:
- ghc: "8.10.7"
yaml: "stack-8.10.7.yaml"
- ghc: "9.0.2"
yaml: "stack-9.0.2-aeson1.yaml"
- ghc: "9.0.2"
yaml: "stack-9.0.2-aeson2.yaml"
- ghc: "9.2.8"
yaml: "stack-9.2.8.yaml"
- ghc: "9.4.5"
k8s_release:
# - "1.20"
# - "1.21"
# - "1.22"
# - "1.23"
# - "1.24"
- "1.25"
- "1.26"
- "1.27"
- "1.28"
- "1.29"
- "1.30"
compiler:
# - ghc: "8.10.7"
# yaml: "stack-8.10.7.yaml"
# - ghc: "9.0.2"
# yaml: "stack-9.0.2-aeson1.yaml"
# - ghc: "9.0.2"
# yaml: "stack-9.0.2-aeson2.yaml"
# - ghc: "9.2.8"
# yaml: "stack-9.2.8.yaml"
- ghc: "9.4.8"
yaml: "stack-9.4.8.yaml"
- ghc: "9.6.5"
yaml: "stack-9.6.5.yaml"
- ghc: "9.8.2"
yaml: "stack.yaml"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: haskell/actions/setup@v2
- uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
ghc-version: ${{ matrix.compiler.ghc }}
enable-stack: true
stack-version: "latest"

- uses: actions/cache@v3
- uses: cachix/install-nix-action@v27

- uses: actions/cache@v4
name: Cache ~/.stack
with:
path: ~/.stack
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ matrix.yaml }}
key: ${{ runner.os }}-${{ matrix.compiler.ghc }}-${{ matrix.compiler.yaml }}

- name: Build
run: |
stack build --stack-yaml ${{matrix.yaml}} --system-ghc --test --bench --no-run-tests --no-run-benchmarks
nix run .#set-stack-version -- "${{matrix.k8s_release}}" "${{matrix.compiler.yaml}}"

stack build --stack-yaml ${{matrix.compiler.yaml}} --system-ghc --test --bench --no-run-tests --no-run-benchmarks

- name: Test
run: |
stack test --stack-yaml ${{matrix.yaml}} --system-ghc
stack test --stack-yaml ${{matrix.compiler.yaml}} --system-ghc
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ cabal.sandbox.config
.stack-work/
cabal.project.local
.HTF/
swagger.json
swagger.json.unprocessed
git_push.sh
openapi.yaml
19 changes: 19 additions & 0 deletions build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPTDIR"

# This script builds kubernetes-client + kubernetes-client-core for
# all Kubernetes versions.

nix run .#set-stack-version 1.20 stack.yaml && stack build
nix run .#set-stack-version 1.21 stack.yaml && stack build
nix run .#set-stack-version 1.22 stack.yaml && stack build
nix run .#set-stack-version 1.23 stack.yaml && stack build
nix run .#set-stack-version 1.24 stack.yaml && stack build
nix run .#set-stack-version 1.25 stack.yaml && stack build
nix run .#set-stack-version 1.26 stack.yaml && stack build
nix run .#set-stack-version 1.27 stack.yaml && stack build
nix run .#set-stack-version 1.28 stack.yaml && stack build
nix run .#set-stack-version 1.29 stack.yaml && stack build
nix run .#set-stack-version 1.30 stack.yaml && stack build
9 changes: 7 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
packages:
kubernetes
kubernetes-1.21
kubernetes-client
examples
examples

source-repository-package
type: git
location: https://github.com/codedownio/haskell-oidc-client
tag: b70757b85751525cba41316ea9af132d9a43cfaf
99 changes: 99 additions & 0 deletions flake.lock

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

53 changes: 53 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.gen = {
url = "github:kubernetes-client/gen";
flake = false;
};
inputs.gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=release-24.05";

outputs = { self, flake-utils, gen, gitignore, nixpkgs }:
flake-utils.lib.eachSystem ["x86_64-linux"] (system:
let
pkgs = import nixpkgs { inherit system; };

in {
packages = rec {
generate = pkgs.writeShellScriptBin "generate-kubernetes-client-core.sh" ''
export KUBERNETES_VERSION="$1"
PACKAGE_VERSION="$2"
out="kubernetes-$KUBERNETES_VERSION"

# Generate
${pkgs.bash}/bin/bash "${gen}/openapi/haskell.sh" "$out" settings

# Fill in the package version
${pkgs.gnused}/bin/sed -i "s/^version:\s*\(.*\)/version: $PACKAGE_VERSION/" "$out/kubernetes-client-core.cabal"

# Fix a bound
${pkgs.gnused}/bin/sed -i 's/\(http-api-data >= 0.3.4 &&\) <0.6/\1 <0.7/' "$out/kubernetes-client-core.cabal"

# Delete openapi.yaml from the extra-source-files
${pkgs.gnused}/bin/sed -i '/^\s*openapi\.yaml$/d' "$out/kubernetes-client-core.cabal"
'';

set-stack-version = pkgs.writeShellScriptBin "build-kubernetes-client.sh" ''
export KUBERNETES_VERSION="$1"
STACK_YAML="$2"

${pkgs.gnused}/bin/sed -i "s/^- kubernetes-\(1\.\)[0-9]\+/- kubernetes-$KUBERNETES_VERSION/" "$STACK_YAML"
'';

set-cabal-version = pkgs.writeShellScriptBin "build-kubernetes-client.sh" ''
export KUBERNETES_VERSION="$1"
CABAL_PROJECT="$2"

${pkgs.gnused}/bin/sed -i "s/^ kubernetes-\(1\.\)[0-9]\+/ kubernetes-$KUBERNETES_VERSION/" "$CABAL_PROJECT"
'';
};
});
}
21 changes: 21 additions & 0 deletions generate_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPTDIR"

# The first argument is the Kubernetes release to use.
# The second is the package version to place in ./kubernetes-<K8S version>/kubernetes-client-core.cabal.
# The idea is to use the patch number for our own purposes, incrementing when we need to update
# the kubernetes-client-core library.

nix run .#generate -- 1.20 1.20.0
nix run .#generate -- 1.21 1.21.0
nix run .#generate -- 1.22 1.22.0
nix run .#generate -- 1.23 1.23.0
nix run .#generate -- 1.24 1.24.0
nix run .#generate -- 1.25 1.25.0
nix run .#generate -- 1.26 1.26.0
nix run .#generate -- 1.27 1.27.0
nix run .#generate -- 1.28 1.28.0
nix run .#generate -- 1.29 1.29.0
nix run .#generate -- 1.30 1.30.0
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

README.md
2 changes: 2 additions & 0 deletions kubernetes-1.20/.openapi-generator/COMMIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Requested Commit/Tag : ab7d0cb74f6ef95bdaeafd327bbdb5d54f819175
Actual Commit : ab7d0cb74f6ef95bdaeafd327bbdb5d54f819175
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.gitignore
.travis.yml
README.md
Setup.hs
git_push.sh
kubernetes-client-core.cabal
Expand Down
1 change: 1 addition & 0 deletions kubernetes-1.20/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.6.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
19f91fe5110cab07889fb5816d54a140ac5072c7e6e791580eaca741a56bd203
File renamed without changes.
File renamed without changes.
Loading