Skip to content

Commit

Permalink
Merge pull request #972 from CannonLock/issue-971
Browse files Browse the repository at this point in the history
Import parameters.json into website
  • Loading branch information
haoming29 authored Mar 27, 2024
2 parents e60b5d3 + 9a2bda3 commit 696e8d7
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/go-generate-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Check Go Generate Has been Run
on:
pull_request:
jobs:
validate-generated-files:
name: Check Go Generate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"

- name: Run Go Generate
run: go generate ./...

- name: Validate Generated Files are up to date
run: |
if git diff --quiet; then
echo "No changes found."
else
echo "Changes detected. Here are the details:"
git diff
exit 1
fi
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Build the website
run: |
make web-build
- name: Set up Go
uses: actions/setup-go@v5
with:
Expand Down
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ before:
hooks:
- go mod tidy
- go generate ./...
- make web-build
builds:
- env:
- CGO_ENABLED=0
Expand Down
13 changes: 13 additions & 0 deletions generate/param_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,19 @@ func GenParamEnum() {
if err != nil {
panic(err)
}

// Skip writing the file if it is the same as the existing file
// This is so that the file is not updated if it is not changed making builds faster
if _, err := os.Stat("../docs/parameters.json"); err == nil {
existingJsonBytes, err := os.ReadFile("../docs/parameters.json")
if err != nil {
panic(err)
}
if bytes.Equal(existingJsonBytes, prettyJSON.Bytes()) {
return
}
}

// Create the json file to be generated (for the documentation website)
fJSON, err := os.Create("../docs/parameters.json")
if err != nil {
Expand Down
16 changes: 2 additions & 14 deletions images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,14 @@
ARG BASE_YUM_REPO=release
ARG BASE_OSG_SERIES=3.6

FROM node:20 AS website-build

WORKDIR /webapp

COPY web_ui/frontend/package.json package.json

RUN npm install
COPY web_ui/frontend ./

RUN npm run build

FROM goreleaser/goreleaser:v1.21.0 AS pelican-build
ARG IS_NONRELEASE_BUILD="true"

RUN apk add --update nodejs-current npm

WORKDIR /pelican

COPY . .
COPY --from=website-build /webapp/out ./web_ui/frontend/out
# Remove generate package as we already had generated structs in the repo
RUN rm -rf ./generate

ENV GOOS="linux"
ENV GOARCH="amd64"
Expand Down

0 comments on commit 696e8d7

Please sign in to comment.