Skip to content

Commit 971f6b1

Browse files
Merge pull request #1374 from gooddata/snapshot-master-e9b05fe5-to-rel/dev
[bot] Merge master/e9b05fe5 into rel/dev
2 parents 33bfecd + e9b05fe commit 971f6b1

File tree

7 files changed

+346
-6
lines changed

7 files changed

+346
-6
lines changed

.github/actions/hugo-build-action/action.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ runs:
1212
uses: actions/setup-go@v5
1313
with:
1414
go-version: '>=1.20.1'
15+
cache: false
16+
- name: "Cache Go modules"
17+
uses: actions/cache@v4
18+
with:
19+
path: ~/go/pkg/mod
20+
key: go-mod-${{ hashFiles('docs/go.sum') }}
21+
restore-keys: go-mod-
1522
- name: "Setup Node"
1623
uses: actions/setup-node@v4
1724
with:
@@ -28,6 +35,12 @@ runs:
2835
working-directory: ./docs
2936
run: |
3037
npm ci
38+
- name: "Cache Hugo resources"
39+
uses: actions/cache@v4
40+
with:
41+
path: docs/resources/_gen
42+
key: hugo-resources-${{ hashFiles('docs/go.sum', 'docs/config/**') }}
43+
restore-keys: hugo-resources-
3144
- name: "Build documentation"
3245
working-directory: ./docs
3346
env:

.github/actions/hugo-build-versioned-action/action.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ runs:
3535
- uses: actions/setup-go@v5
3636
with:
3737
go-version: '>=1.20.1'
38+
cache: false
39+
- name: "Cache Go modules"
40+
uses: actions/cache@v4
41+
with:
42+
path: ~/go/pkg/mod
43+
key: go-mod-${{ hashFiles('docs/go.sum') }}
44+
restore-keys: go-mod-
3845
- name: "Setup Node"
3946
uses: actions/setup-node@v4
4047
with:
@@ -59,6 +66,12 @@ runs:
5966
wget https://raw.githubusercontent.com/gooddata/gooddata-python-sdk/master/scripts/generate.sh
6067
chmod +x ./generate.sh
6168
./generate.sh ${{ inputs.fetch-from }} master
69+
- name: "Cache Hugo resources"
70+
uses: actions/cache@v4
71+
with:
72+
path: docs/resources/_gen
73+
key: hugo-resources-${{ hashFiles('docs/go.sum', 'docs/config/**') }}
74+
restore-keys: hugo-resources-
6275
- name: "Build documentation"
6376
working-directory: ./docs
6477
env:
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Netlify Deploy V2 (Draft)
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
# Job 1: Discover which version branches to build
7+
discover-versions:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
matrix: ${{ steps.versions.outputs.matrix }}
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
- name: Fetch remote refs
15+
run: git fetch origin
16+
- name: Discover versions
17+
id: versions
18+
run: |
19+
MATRIX=$(bash scripts/discover-versions.sh origin 4)
20+
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
21+
echo "Discovered versions: $MATRIX"
22+
23+
# Job 2: Generate docs for each version (matrix — runs in parallel across versions)
24+
# Each version gets its own runner with that branch's SDK installed.
25+
# Per-version caching means released branches (which rarely change) are instant cache hits.
26+
generate-version:
27+
needs: [discover-versions]
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
version: ${{ fromJson(needs.discover-versions.outputs.matrix) }}
32+
fail-fast: false
33+
steps:
34+
- name: Get branch commit SHA
35+
id: sha
36+
env:
37+
GH_TOKEN: ${{ github.token }}
38+
run: |
39+
SHA=$(gh api "repos/${{ github.repository }}/git/ref/heads/${{ matrix.version.branch }}" -q '.object.sha')
40+
echo "sha=$SHA" >> $GITHUB_OUTPUT
41+
echo "Branch ${{ matrix.version.branch }} -> section ${{ matrix.version.section }} (SHA: $SHA)"
42+
- name: Cache version docs
43+
id: cache
44+
uses: actions/cache@v4
45+
with:
46+
path: docs/versioned_docs/${{ matrix.version.section }}
47+
key: version-docs-${{ matrix.version.section }}-${{ steps.sha.outputs.sha }}
48+
- name: Checkout
49+
if: steps.cache.outputs.cache-hit != 'true'
50+
uses: actions/checkout@v4
51+
- name: Fetch target branch
52+
if: steps.cache.outputs.cache-hit != 'true'
53+
run: git fetch origin ${{ matrix.version.branch }}
54+
- name: Checkout branch packages
55+
if: steps.cache.outputs.cache-hit != 'true'
56+
run: |
57+
git checkout origin/${{ matrix.version.branch }} -- gooddata-api-client/ packages/gooddata-sdk/ packages/gooddata-pandas/ scripts/script-requirements.txt
58+
- name: Setup Python
59+
if: steps.cache.outputs.cache-hit != 'true'
60+
uses: actions/setup-python@v5
61+
with:
62+
python-version-file: ".python-version"
63+
cache: 'pip'
64+
cache-dependency-path: scripts/script-requirements.txt
65+
- name: Install Dependencies
66+
if: steps.cache.outputs.cache-hit != 'true'
67+
run: |
68+
python -m pip install --upgrade pip
69+
pip install -r scripts/script-requirements.txt
70+
- name: Generate version docs
71+
if: steps.cache.outputs.cache-hit != 'true'
72+
run: bash scripts/generate-single-version.sh "origin/${{ matrix.version.branch }}" "${{ matrix.version.section }}"
73+
- name: Upload version artifact
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: version-${{ matrix.version.section }}
77+
path: docs/versioned_docs/${{ matrix.version.section }}
78+
retention-days: 1
79+
80+
# Job 3: Assemble all versions, build Hugo site, and deploy to Netlify (draft)
81+
build-and-deploy:
82+
needs: [generate-version]
83+
runs-on: ubuntu-latest
84+
steps:
85+
- name: Checkout
86+
uses: actions/checkout@v4
87+
with:
88+
submodules: recursive
89+
- name: Setup GO
90+
uses: actions/setup-go@v5
91+
with:
92+
go-version: '>=1.20.1'
93+
cache: false
94+
- name: Cache Go modules
95+
uses: actions/cache@v4
96+
with:
97+
path: ~/go/pkg/mod
98+
key: go-mod-${{ hashFiles('docs/go.sum') }}
99+
restore-keys: go-mod-
100+
- name: Setup Node
101+
uses: actions/setup-node@v4
102+
with:
103+
node-version: 20
104+
cache: 'npm'
105+
cache-dependency-path: docs/package-lock.json
106+
- name: Install Hugo
107+
run: npm install -g hugo-extended@0.117.0
108+
- name: Install Dependencies
109+
working-directory: ./docs
110+
run: npm ci
111+
- name: Download version artifacts
112+
uses: actions/download-artifact@v4
113+
with:
114+
pattern: version-*
115+
path: docs/versioned_docs-raw/
116+
- name: Assemble versioned docs
117+
working-directory: ./docs
118+
run: bash ../scripts/assemble-versions.sh
119+
- name: Cache Hugo resources
120+
uses: actions/cache@v4
121+
with:
122+
path: docs/resources/_gen
123+
key: hugo-resources-${{ hashFiles('docs/go.sum', 'docs/config/**') }}
124+
restore-keys: hugo-resources-
125+
- name: Build documentation
126+
working-directory: ./docs
127+
run: hugo --minify --baseURL https://www.gooddata.com/docs/python-sdk
128+
- name: Publish (draft)
129+
uses: netlify/actions/cli@master
130+
with:
131+
args: deploy -d docs/public
132+
env:
133+
NETLIFY_SITE_ID: 93e23db0-d31a-4a12-801a-b9479ffef486 # Not a secret
134+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

docs/Dockerfile

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1+
# syntax=docker/dockerfile:1
12
FROM python:3.14-slim AS builder
23

34
RUN apt-get update && apt-get install -y git make curl
45

6+
# Install Python deps first (changes rarely) for better layer caching.
7+
# Copy only dependency manifests and package source before installing.
58
COPY scripts/script-requirements.txt /scripts/script-requirements.txt
6-
COPY docs docs
7-
COPY scripts/docs/ /docs
89
COPY gooddata-api-client /gooddata-api-client
910
COPY packages/gooddata-sdk /gooddata-sdk
1011
COPY packages/gooddata-pandas /gooddata-pandas
1112

12-
RUN pip install --no-cache-dir -r /scripts/script-requirements.txt
13+
RUN --mount=type=cache,target=/root/.cache/pip \
14+
pip install -r /scripts/script-requirements.txt
15+
16+
# Copy source (docs content changes most frequently, scripts less so)
17+
COPY docs docs
18+
COPY scripts/docs/ /docs
1319

1420
WORKDIR /docs
1521

@@ -21,16 +27,20 @@ RUN python json_builder.py && \
2127

2228
FROM node:20.18.0-bookworm-slim
2329

24-
COPY --from=builder /docs /docs
25-
2630
RUN apt-get update && \
2731
apt-get install -y git make golang-go curl && \
2832
npm install -g hugo-extended@0.117.0 && \
2933
apt-get clean && \
3034
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
3135

36+
COPY --from=builder /docs /docs
37+
3238
WORKDIR /docs
33-
RUN npm install && \
39+
40+
# Use BuildKit cache mounts so npm/Go package downloads survive layer rebuilds
41+
RUN --mount=type=cache,target=/root/.npm \
42+
--mount=type=cache,target=/root/go/pkg/mod \
43+
npm install && \
3444
hugo mod get
3545

3646
# accessible on http://localhost:1313/latest/

scripts/assemble-versions.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
# (C) 2026 GoodData Corporation
3+
# Assembles version artifacts into the final versioned_docs structure.
4+
# Run from the docs/ directory after downloading version artifacts.
5+
#
6+
# Expects:
7+
# - versioned_docs-raw/ directory with version-* subdirectories (from artifact download)
8+
# - content/en/ directory with master branch content (from current checkout)
9+
set -e
10+
11+
content_dir=versioned_docs
12+
13+
# Start with clean versioned_docs
14+
rm -rf "$content_dir"
15+
mkdir -p "$content_dir"
16+
17+
# 1. Copy master/current branch content (provides versions page and root structure)
18+
echo "Copying master content from content/en/"
19+
cp -r content/en/. "$content_dir/"
20+
21+
# 2. Move version artifacts from download directory into versioned_docs
22+
if [ -d "versioned_docs-raw" ]; then
23+
for dir in versioned_docs-raw/version-*/; do
24+
[ -d "$dir" ] || continue
25+
section=$(basename "$dir" | sed 's/^version-//')
26+
echo "Installing version artifact: $section"
27+
# Remove any existing content for this section (from master copy)
28+
rm -rf "${content_dir:?}/$section"
29+
mv "$dir" "$content_dir/$section"
30+
done
31+
rm -rf versioned_docs-raw
32+
fi
33+
34+
# 3. Remove master's "latest" directory — it will be replaced by the highest numbered version
35+
echo "Removing master's latest directory"
36+
rm -rf "${content_dir:?}/latest"
37+
38+
# 4. Find the highest numbered version and promote it to "latest"
39+
highest_version=$(ls -1 "./$content_dir/" | grep -E '^[0-9]+$' | sort -V | tail -n 1)
40+
41+
if [ -n "$highest_version" ]; then
42+
echo "Promoting version $highest_version to /latest"
43+
mv -f "./$content_dir/$highest_version" "./$content_dir/latest"
44+
45+
# Update version references in links.json
46+
if [ -f "./$content_dir/latest/links.json" ]; then
47+
sed "s|${highest_version}|latest|g" "./$content_dir/latest/links.json" > temp_links.json
48+
mv temp_links.json "./$content_dir/latest/links.json"
49+
fi
50+
else
51+
echo "WARNING: No numbered version directory found to promote to latest"
52+
fi
53+
54+
echo "Assembly complete. Contents of $content_dir/:"
55+
ls -la "$content_dir/"

scripts/discover-versions.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# (C) 2026 GoodData Corporation
3+
# Discovers release versions for parallel doc generation.
4+
# Outputs a JSON array suitable for GitHub Actions matrix strategy.
5+
# Usage: discover-versions.sh [remote_name] [num_versions]
6+
set -e
7+
8+
remote_name=${1:-origin}
9+
num_versions=${2:-4}
10+
11+
git fetch "$remote_name" 2>/dev/null
12+
13+
# Build a map of section -> branch, keeping only the latest minor per section.
14+
# Associative arrays preserve last-write-wins semantics, matching the original
15+
# generate.sh behavior where later branches overwrite earlier ones.
16+
declare -A section_map
17+
declare -a section_order
18+
19+
while IFS= read -r vers; do
20+
section="${vers%.*}"
21+
if [ -z "${section_map[$section]+x}" ]; then
22+
section_order+=("$section")
23+
fi
24+
# Later (higher minor) versions overwrite earlier ones for the same major
25+
section_map["$section"]="rel/$vers"
26+
done < <(git branch -rl "$remote_name/rel/*" | sed 's|.*/rel/||' | grep -E '^[0-9]+\.[0-9]+$' | sort -t. -k1,1n -k2,2n | tail -n"$num_versions")
27+
28+
# Add dev branch if it exists
29+
if git branch -rl "$remote_name/rel/dev" | grep -q "rel/dev"; then
30+
if [ -z "${section_map[dev]+x}" ]; then
31+
section_order+=("dev")
32+
fi
33+
section_map["dev"]="rel/dev"
34+
fi
35+
36+
# Output as JSON array
37+
echo -n "["
38+
first=true
39+
for section in "${section_order[@]}"; do
40+
branch="${section_map[$section]}"
41+
if [ "$first" = true ]; then
42+
first=false
43+
else
44+
echo -n ","
45+
fi
46+
echo -n "{\"branch\":\"$branch\",\"section\":\"$section\"}"
47+
done
48+
echo "]"

0 commit comments

Comments
 (0)