Skip to content

Commit

Permalink
Upgrade Hugo version from 0.115.4 to 0.119.0 (#1507)
Browse files Browse the repository at this point in the history
* Upgrade hugo to 0.119.0
  • Loading branch information
ibrahimjaved12 authored Feb 10, 2025
1 parent 42cccee commit ed05974
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 76 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"exec-sh": "^0.4.0",
"file-loader": "^5.0.2",
"hugo-bin-extended": "0.115.4",
"hugo-bin-extended": "^0.119.0",
"imports-loader": "^0.8.0",
"inquirer": "^12.0.0",
"jest": "^27.4.7",
Expand Down
141 changes: 71 additions & 70 deletions tests-e2e/jest/build-failures.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "node:path"
import { IncomingMessage } from "node:http"
import { IncomingMessage, ServerResponse } from "node:http"
import LocalOCW from "../LocalOcw"
import { TestSiteAlias } from "../util/test_sites"

Expand Down Expand Up @@ -35,9 +35,11 @@ describe("OCW Build Failures", () => {
beforeEach(async () => {
await ocw.rmrfTmp()
})

beforeAll(() => {
ocw.fixturesServer.listen()
})

afterAll(() => {
ocw.fixturesServer.close()
})
Expand All @@ -46,87 +48,86 @@ describe("OCW Build Failures", () => {
ocw.fixturesServer.resetHandler()
})

test.each([
{
statusCode: 404,
match: [/Failed to fetch instructors/, /from .*4322\/instructors/]
},
{
statusCode: 504,
match: [
/Failed to fetch instructors/,
/from .*4322\/instructors/,
/with error.* Gateway Timeout/
]
}
])(
"Instructor static API errors crash build",
async ({ statusCode, match }) => {
describe("Instructor static API errors crash build", () => {
const patchInstructorRequest = (responder: (attempt: number) => number) => {
let attempt = 0
const shouldPatch = (req: IncomingMessage) =>
req.url?.includes("3caa0884-4fdd-4f3c-ba39-67a64c27d877")
ocw.fixturesServer.patchHandler((req, res) => {
if (shouldPatch(req)) {
res.writeHead(statusCode)
res.end()
ocw.fixturesServer.patchHandler(
(req: IncomingMessage, res: ServerResponse) => {
if (shouldPatch(req)) {
attempt++
const statusCode = responder(attempt)
res.writeHead(statusCode)
res.end()
}
}
})
)
}

test("should return 504 on the first request then 404 for subsequent requests", async () => {
patchInstructorRequest(attempt => (attempt === 1 ? 504 : 404))

await expectBuildError(ocw, "course", match)
await expectBuildError(ocw, "course", [
/Failed to fetch instructors/,
/from .*4322\/instructors/
])
})
})

describe("Featured course static API failures for featured course", () => {
const patchFeaturedCourseRequest = (
responder: (attempt: number) => number
) => {
let attempt = 0
const shouldPatch = (req: IncomingMessage) =>
req.url?.includes("some-featured-course")
ocw.fixturesServer.patchHandler(
(req: IncomingMessage, res: ServerResponse) => {
if (shouldPatch(req)) {
attempt++
const statusCode = responder(attempt)
res.writeHead(statusCode)
res.end()
}
}
)
}
)

test.each([
{
statusCode: 404,
match: [
test("should return 504 on the first request then 404 for subsequent requests", async () => {
patchFeaturedCourseRequest(attempt => (attempt === 1 ? 504 : 404))

await expectBuildError(ocw, "www", [
/Failed to fetch featured course info/,
/from .*4322\/courses\/some-featured-course/
]
},
{
statusCode: 504,
match: [
/Failed to fetch featured course info/,
/from .*4322\/courses\/some-featured-course.*/,
/with error.* Gateway Timeout/
]
}
])("Featured course static API failures", async ({ statusCode, match }) => {
const shouldPatch = (req: IncomingMessage) =>
req.url?.includes("some-featured-course")
ocw.fixturesServer.patchHandler((req, res) => {
if (shouldPatch(req)) {
res.writeHead(statusCode)
res.end()
}
])
})

await expectBuildError(ocw, "www", match)
})

test.each([
{
statusCode: 404,
match: [/Failed to fetch new course info/]
},
{
statusCode: 504,
match: [
/Failed to fetch new course info/,
/from .*4322\/courses\/some-new-course.*/,
/with error.* Gateway Timeout/
]
describe("Featured course static API failures for new course", () => {
const patchNewCourseRequest = (responder: (attempt: number) => number) => {
let attempt = 0
const shouldPatch = (req: IncomingMessage) =>
req.url?.includes("some-new-course")
ocw.fixturesServer.patchHandler(
(req: IncomingMessage, res: ServerResponse) => {
if (shouldPatch(req)) {
attempt++
const statusCode = responder(attempt)
res.writeHead(statusCode)
res.end()
}
}
)
}
])("Featured course static API failures", async ({ statusCode, match }) => {
const shouldPatch = (req: IncomingMessage) =>
req.url?.includes("some-new-course")
ocw.fixturesServer.patchHandler((req, res) => {
if (shouldPatch(req)) {
res.writeHead(statusCode)
res.end()
}
})

await expectBuildError(ocw, "www", match)
test("should return 504 on the first request then 404 for subsequent requests", async () => {
patchNewCourseRequest(attempt => (attempt === 1 ? 504 : 404))

await expectBuildError(ocw, "www", [
/Failed to fetch new course info/,
/from .*4322\/courses\/some-new-course.*/
])
})
})
})
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8021,15 +8021,15 @@ __metadata:
languageName: node
linkType: hard

"hugo-bin-extended@npm:0.115.4":
version: 0.115.4
resolution: "hugo-bin-extended@npm:0.115.4"
"hugo-bin-extended@npm:^0.119.0":
version: 0.119.0
resolution: "hugo-bin-extended@npm:0.119.0"
dependencies:
"@xhmikosr/bin-wrapper": ^11.0.2
pkg-conf: ^4.0.0
bin:
hugo: bin/cli.js
checksum: d486eefbf5d11b94a2a7005b15a43d77e4a66bb967a0cfdf0cced3ccce64f2e975ce8c9474fe1309decbb2d70de92fd14103cd3ba3471a40f87671c05b99f70c
checksum: f88c90350bb5fac46b983672167ab5691bd6aa8f8847e7196609bc7144b4eac0580c34d05a2409a454cced1b5b92922d29cd95ae2b410d06a2302127dd1216d2
languageName: node
linkType: hard

Expand Down Expand Up @@ -11218,7 +11218,7 @@ __metadata:
file-loader: ^5.0.2
fuse.js: ^6.6.2
history: ^5.3.0
hugo-bin-extended: 0.115.4
hugo-bin-extended: ^0.119.0
imports-loader: ^0.8.0
inquirer: ^12.0.0
isomorphic-fetch: ^3.0.0
Expand Down

0 comments on commit ed05974

Please sign in to comment.