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

release(v0.48.0): merge to master #1563

Merged
merged 5 commits into from
Oct 4, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v0.48.0](https://github.com/isomerpages/isomercms-frontend/compare/v0.47.1...v0.48.0)

- Fix/styles [`#1560`](https://github.com/isomerpages/isomercms-frontend/pull/1560)
- fix(e2e): utlise new backend endpoint to reset e2e repos [`#1536`](https://github.com/isomerpages/isomercms-frontend/pull/1536)
- Hotfix/v0.47.1 [`#1557`](https://github.com/isomerpages/isomercms-frontend/pull/1557)
- release(0.47.0): merge to `develop` [`#1553`](https://github.com/isomerpages/isomercms-frontend/pull/1553)

#### [v0.47.1](https://github.com/isomerpages/isomercms-frontend/compare/v0.47.0...v0.47.1)

> 3 October 2023

- fix(hero.scss): css fix [`af09212`](https://github.com/isomerpages/isomercms-frontend/commit/af09212f81dbf845eae7579632fecb2a26d3eb1a)

#### [v0.47.0](https://github.com/isomerpages/isomercms-frontend/compare/v0.46.0...v0.47.0)
Expand Down
16 changes: 2 additions & 14 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isomercms-frontend",
"version": "0.47.1",
"version": "0.48.0",
"private": true,
"engines": {
"node": ">=16.0.0"
Expand Down Expand Up @@ -159,7 +159,6 @@
"@typescript-eslint/parser": "^5.55.0",
"auto-changelog": "^2.4.0",
"babel-jest": "^29.5.0",
"btoa": "^1.2.1",
"chromatic": "^6.5.6",
"cypress": "^12.8.0",
"cypress-pipe": "^2.0.0",
Expand Down
90 changes: 44 additions & 46 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@
const { spawn } = require("child_process")

const axios = require("axios")
const btoa = require("btoa")

// login credentials
const { PERSONAL_ACCESS_TOKEN, USERNAME } = process.env
if (!PERSONAL_ACCESS_TOKEN || !USERNAME) {
// Login credentials
const {
CYPRESS_COOKIE_NAME,
CYPRESS_COOKIE_VALUE,
CYPRESS_BACKEND_URL,
} = process.env
if (!CYPRESS_COOKIE_NAME || !CYPRESS_COOKIE_VALUE) {
throw new Error(
`E2E tests require env vars PERSONAL_ACCESS_TOKEN (${PERSONAL_ACCESS_TOKEN}) and USERNAME (${USERNAME}) to be set.`
`E2E tests require env vars CYPRESS_COOKIE_NAME and CYPRESS_COOKIE_VALUE to be set.`
)
}

const CREDENTIALS = `${USERNAME}:${PERSONAL_ACCESS_TOKEN}`
const headers = {
authorization: `basic ${btoa(CREDENTIALS)}`,
accept: "application/json",
const emailHeaders = {
Cookie: `${CYPRESS_COOKIE_NAME}=${CYPRESS_COOKIE_VALUE}; e2eUserType=Email admin; site=e2e email test site; [email protected]`,
}

// cypress commands
const githubHeaders = {
Cookie: `${CYPRESS_COOKIE_NAME}=${CYPRESS_COOKIE_VALUE}; e2eUserType=Github user`,
}

// Cypress test runner
const cypressCommand = process.argv[2] // either `run` or `open`
const baseCypressCommand = `npx cypress ${cypressCommand}`
// if we are running tests, record them on the dashboard so that github will show the corresponding status
Expand All @@ -27,49 +32,40 @@ const runCypressCommand =
? `${baseCypressCommand} --record`
: baseCypressCommand

// reset e2e-test-repo
const { E2E_COMMIT_HASH } = process.env
if (!E2E_COMMIT_HASH) {
throw new Error(
`E2E tests require env var E2E_COMMIT_HASH (${E2E_COMMIT_HASH}) to be set.`
)
// E2E test repositories
const e2eTestRepositoriesWithHashes = {
"e2e-test-repo": "bcfe46da1288b3302c5bb5f72c5c58b50574f26c",
"e2e-email-test-repo": "93593ceb8ee8af690267e49ea787701fc73baed8",
"e2e-notggs-test-repo": "1ccc5253dd06e06a088d1e6ec86a38c870c0a3d6",
}
const GITHUB_ORG_NAME = "isomerpages"
const E2E_GITHUB_REPO_NAME = "e2e-test-repo"
const E2E_EMAIL_REPO_NAME = "e2e-email-test-repo"
const E2E_EMAIL_COMMIT_HASH = "93593ceb8ee8af690267e49ea787701fc73baed8"

const resetRepo = async (repo, hash, branch) => {
const endpoint = `https://api.github.com/repos/${GITHUB_ORG_NAME}/${repo}/git/refs/heads/${branch}`
await axios.patch(
// Reset test repositories
const resetRepository = async (repository, branchName, userType) => {
const endpoint = `${CYPRESS_BACKEND_URL}/sites/${repository}/admin/resetRepo`
const headers = userType === "github" ? githubHeaders : emailHeaders
await axios.post(
endpoint,
{
sha: hash,
force: true,
commitSha: e2eTestRepositoriesWithHashes[repository],
branchName,
},
{
headers,
}
{ headers },
{ withCredentials: true }
)
console.log(
`Successfully reset ${repository} (${branchName}) to ${e2eTestRepositoriesWithHashes[repository]}}`
)
console.log(`Successfully reset ${repo} to ${hash}`)
}

const resetGithubE2eTestRepo = () =>
resetRepo(E2E_GITHUB_REPO_NAME, E2E_COMMIT_HASH, "staging")

const resetEmailE2eTestRepo = () => {
resetRepo(E2E_EMAIL_REPO_NAME, E2E_EMAIL_COMMIT_HASH, "staging")
resetRepo(E2E_EMAIL_REPO_NAME, E2E_EMAIL_COMMIT_HASH, "master")
}

const resetE2eTestRepo = async () => {
await resetGithubE2eTestRepo()
await resetEmailE2eTestRepo()
const resetE2ETestRepositories = async () => {
resetRepository("e2e-test-repo", "staging", "github")
resetRepository("e2e-notggs-test-repo", "staging", "github")
resetRepository("e2e-email-test-repo", "staging", "email")
resetRepository("e2e-email-test-repo", "master", "email")
}

// resets the e2e repo then runs the corresponding cypress command
const runE2eTests = async () =>
resetE2eTestRepo()
const runE2ETests = async () => {
resetE2ETestRepositories()
.then(() => {
const child = spawn(runCypressCommand, { shell: true })
child.stderr.on("data", (data) => {
Expand All @@ -83,7 +79,8 @@ const runE2eTests = async () =>
// NOTE: Cypress uses the exit code to show the number of failed tests.
// If we do not exit here, the child process (that's running the test) will not be able to feedback
// to Github Actions if the tests pass.
process.exit(exitCode)
// If exitCode is null, means that the child process was killed by a signal.
process.exit(exitCode || 1)
})
})
.catch((err) => {
Expand All @@ -92,8 +89,9 @@ const runE2eTests = async () =>
// This also prevents CI from recording this as a successful step.
process.exit(1)
})
}

module.exports = {
runE2eTests,
resetE2eTestRepo,
runE2ETests,
resetE2ETestRepositories,
}
4 changes: 2 additions & 2 deletions scripts/reset-e2e.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const { resetE2eTestRepo } = require("./build")
const { resetE2ETestRepositories } = require("./build")

resetE2eTestRepo()
resetE2ETestRepositories()
4 changes: 2 additions & 2 deletions scripts/run-e2e.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const { runE2eTests } = require("./build")
const { runE2ETests } = require("./build")

runE2eTests()
runE2ETests()
3 changes: 1 addition & 2 deletions src/layouts/components/Homepage/AnnouncementBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ export const AnnouncementBody = ({
<Editable.Droppable editableId="announcement">
<Text textStyle="h5">Announcements</Text>
<Text mt="0.5rem" textStyle="body-2" textColor="base.content.medium">
{`You can display up to ${MAX_ANNOUNCEMENTS} announcements at a time. Newly added
announcements are shown on the top of the list`}
{`You can display up to ${MAX_ANNOUNCEMENTS} announcements at a time.`}
</Text>

<Editable.Accordion
Expand Down
8 changes: 6 additions & 2 deletions src/layouts/components/Homepage/HeroBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,14 @@ export const HeroBody = ({
<Divider my="1.5rem" />
<Editable.Section spacing="0.75rem">
<Box w="100%">
<Text textStyle="h5" mb="0.75rem">
<Text textStyle="h5" mb="1rem">
Hero Interactions
</Text>
<Text textStyle="subhead-1" mb="0.25rem">
<Text
textStyle="subhead-1"
mb="0.25rem"
textColor="base.content.strong"
>
Content type
</Text>
<Radio.RadioGroup
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/components/Homepage/HeroHighlightSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const HeroHighlightSection = ({
<Editable.Droppable editableId="highlight">
<VStack spacing="1.25rem" align="flex-start" p={0}>
<FormControl isRequired isInvalid={!!errors.button}>
<FormLabel>Button Text</FormLabel>
<FormLabel>Button text</FormLabel>
<Input
id="section-0-hero-button"
placeholder="This is a button"
Expand Down
Loading
Loading