Skip to content
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
24 changes: 19 additions & 5 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,26 @@ jobs:
run: npx playwright merge-reports --reporter html "$RUNNER_TEMP/all-blob-reports"

- name: Upload HTML report artifact
# Upload HTML report to GitHub Actions Artifacts only for pull requests from forks
if: steps.check-reports.outputs.has_reports == 'true' && (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)
# Keep reports in GitHub when S3 publishing is not configured or the pull request comes from a fork.
if: >-
steps.check-reports.outputs.has_reports == 'true' &&
(
vars.AWS_REGION == '' ||
vars.AWS_BUCKET_NAME == '' ||
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)
)
uses: actions/upload-artifact@v5
with:
name: playwright-html-report
path: playwright-report
retention-days: 7

- name: Configure AWS credentials
if: steps.check-reports.outputs.has_reports == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
if: >-
steps.check-reports.outputs.has_reports == 'true' &&
vars.AWS_REGION != '' &&
vars.AWS_BUCKET_NAME != '' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -341,7 +351,11 @@ jobs:

- name: Upload HTML report to S3
# Upload HTML report to S3 only for pull requests from the main repository or for non-pull requests events
if: steps.check-reports.outputs.has_reports == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
if: >-
steps.check-reports.outputs.has_reports == 'true' &&
vars.AWS_REGION != '' &&
vars.AWS_BUCKET_NAME != '' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
run: |
export "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`"
aws s3 cp playwright-report/ s3://${{ vars.AWS_BUCKET_NAME }}/report-${SHORT_SHA} --recursive
Expand All @@ -356,4 +370,4 @@ jobs:
else
echo "Download the **playwright-html-report** artifact below to view the report (open \`index.html\` in a browser)." >> $GITHUB_STEP_SUMMARY
fi
echo "[Read about ducks](https://animalkingdom.org/animals/ducks/)" >> $GITHUB_STEP_SUMMARY
echo "[Read about ducks](https://animalkingdom.org/animals/ducks/)" >> $GITHUB_STEP_SUMMARY
9 changes: 9 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,12 @@ jobs:
build-args: |
GIT_COMMIT_SHA=${{ env.SHORT_SHA }}
GIT_TAG=${{ github.ref_type == 'tag' && github.ref_name || '' }}

- name: Update Docker Hub description
if: vars.DOCKERHUB_USERNAME != '' && vars.DOCKERHUB_ORG != ''
uses: peter-evans/dockerhub-description@432a30c9e07499fd01da9f8a49f0faf9e0ca5b77 # v4
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ vars.DOCKERHUB_ORG }}/blockscout-frontend
readme-filepath: ./README.md
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ Alternatively, you can build your own docker image and run your app from that. P

For more information on migrating from the previous frontend, please see the [frontend migration docs](https://docs.blockscout.com/setup/deployment/frontend-migration).

### Custom footer version links

This image supports runtime configuration of the repository links behind the backend and frontend version labels in the footer:

```sh
NEXT_PUBLIC_BACKEND_REPO_URL=https://github.com/my-org/blockscout
NEXT_PUBLIC_FRONTEND_REPO_URL=https://github.com/my-org/blockscout-frontend
NEXT_PUBLIC_VERSION_LINK_TYPE=release
```

The defaults remain the upstream Blockscout repositories with `tree` links. Set `NEXT_PUBLIC_VERSION_LINK_TYPE=release` when your fork publishes matching GitHub releases. See the [footer environment variables](https://github.com/DOS/DOScan-Frontend/blob/main/docs/ENVS.md#footer) for details.

## Contributing

See our [Contribution guide](./docs/CONTRIBUTING.md) for pull request protocol. We expect contributors to follow our [code of conduct](./CODE_OF_CONDUCT.md) when submitting code or comments.
Expand Down
3 changes: 3 additions & 0 deletions deploy/tools/envs-validator/schemas/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,13 @@ const footerLinkGroupSchema: yup.ObjectSchema<CustomLinksGroup> = yup
});

export const footerSchema = yup.object({
NEXT_PUBLIC_BACKEND_REPO_URL: yup.string().test(urlTest),
NEXT_PUBLIC_FRONTEND_REPO_URL: yup.string().test(urlTest),
NEXT_PUBLIC_FOOTER_LINKS: yup
.array()
.json()
.of(footerLinkGroupSchema),
NEXT_PUBLIC_VERSION_LINK_TYPE: yup.string().oneOf([ 'tree', 'release' ]),
});

const fontFamilySchema: yup.ObjectSchema<FontFamily> = yup
Expand Down
3 changes: 3 additions & 0 deletions deploy/tools/envs-validator/test/.env.base
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ NEXT_PUBLIC_NAVIGATION_LAYOUT=horizontal
NEXT_PUBLIC_FONT_FAMILY_HEADING={'name':'Montserrat','url':'https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap'}
NEXT_PUBLIC_FONT_FAMILY_BODY={'name':'Raleway','url':'https://fonts.googleapis.com/css2?family=Raleway:wght@400;500;600;700&display=swap'}
NEXT_PUBLIC_FOOTER_LINKS=https://example.com
NEXT_PUBLIC_BACKEND_REPO_URL=https://github.com/blockscout/blockscout
NEXT_PUBLIC_FRONTEND_REPO_URL=https://github.com/blockscout/frontend
NEXT_PUBLIC_VERSION_LINK_TYPE=release
NEXT_PUBLIC_HELIA_VERIFIED_FETCH_ENABLED=false
NEXT_PUBLIC_HIDE_INDEXING_ALERT_BLOCKS=false
NEXT_PUBLIC_HIDE_INDEXING_ALERT_INT_TXS=false
Expand Down
4 changes: 4 additions & 0 deletions docs/ENVS.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,13 @@ Operator-supplied favicon override. The app ships with the generic Blockscout fa

| Variable | Type | Description | Compulsoriness | Default value | Example value | Version |
| --- | --- | --- | --- | --- | --- | --- |
| NEXT_PUBLIC_BACKEND_REPO_URL | `string` | Repository base URL used by the backend version link in the footer | - | `https://github.com/blockscout/blockscout` | `https://github.com/my-org/blockscout` | v2.9.5+ |
| NEXT_PUBLIC_FRONTEND_REPO_URL | `string` | Repository base URL used by the frontend version link in the footer | - | `https://github.com/blockscout/frontend` | `https://github.com/my-org/blockscout-frontend` | v2.9.5+ |
| NEXT_PUBLIC_FOOTER_LINKS | `string` | URL of configuration file (`.json` format only) or file content string representation. It contains list of link groups to be displayed in the footer. See [below](#footer-links-configuration-properties) list of available properties for particular group | - | - | `https://example.com/footer_links_config.json` \| `[{'title':'My chain','links':[{'text':'About','url':'https://example.com/about'},{'text':'Contacts','url':'https://example.com/contacts'}]}]` | v1.1.1+ |
| NEXT_PUBLIC_VERSION_LINK_TYPE | `tree \| release` | Link version labels to a repository tree or a GitHub release. Commit-only frontend builds always link to the commit | - | `tree` | `release` | v2.9.5+ |

The app version shown in the footer is derived from build-time ENV variables `NEXT_PUBLIC_GIT_TAG` and `NEXT_PUBLIC_GIT_COMMIT_SHA` and cannot be overwritten at run-time.
The repository targets and link type can be overwritten at run-time with the variables above. When `release` is selected, a backend value such as `v11.2.3.+commit.f64bbacb` links to `/releases/tag/v11.2.3`.

#### Footer links configuration properties

Expand Down
18 changes: 15 additions & 3 deletions src/shell/footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,16 @@ import { getApiVersionUrl } from './get-api-version-url';

const MAX_LINKS_COLUMNS = 4;

const FRONT_VERSION_URL = `https://github.com/blockscout/frontend/tree/${ config.shell.footer.frontendVersion }`;
const FRONT_COMMIT_URL = `https://github.com/blockscout/frontend/commit/${ config.shell.footer.frontendCommit }`;
const FRONT_VERSION_URL = config.shell.footer.frontendVersion ?
getApiVersionUrl(
config.shell.footer.frontendVersion,
config.shell.footer.frontendRepoUrl,
config.shell.footer.versionLinkType,
) :
undefined;
const FRONT_COMMIT_URL = `${ config.shell.footer.frontendRepoUrl.replace(/\/+$/, '') }/commit/${
config.shell.footer.frontendCommit
}`;

const Footer = () => {

Expand All @@ -44,7 +52,11 @@ const Footer = () => {
refetchOnMount: false,
},
});
const apiVersionUrl = getApiVersionUrl(backendVersionData?.backend_version ?? undefined);
const apiVersionUrl = getApiVersionUrl(
backendVersionData?.backend_version ?? undefined,
config.shell.footer.backendRepoUrl,
config.shell.footer.versionLinkType,
);

const BLOCKSCOUT_LINKS = [
{
Expand Down
3 changes: 3 additions & 0 deletions src/shell/footer/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import { getEnvValue, getExternalAssetFilePath } from 'src/config/utils/envs';

const config = Object.freeze({
backendRepoUrl: getEnvValue('NEXT_PUBLIC_BACKEND_REPO_URL') || 'https://github.com/blockscout/blockscout',
frontendRepoUrl: getEnvValue('NEXT_PUBLIC_FRONTEND_REPO_URL') || 'https://github.com/blockscout/frontend',
links: getExternalAssetFilePath('NEXT_PUBLIC_FOOTER_LINKS'),
frontendVersion: getEnvValue('NEXT_PUBLIC_GIT_TAG'),
frontendCommit: getEnvValue('NEXT_PUBLIC_GIT_COMMIT_SHA'),
versionLinkType: getEnvValue('NEXT_PUBLIC_VERSION_LINK_TYPE') === 'release' ? 'release' : 'tree',
});

export default config;
31 changes: 31 additions & 0 deletions src/shell/footer/get-api-version-url.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: LicenseRef-Blockscout

import { describe, expect, it } from 'vitest';

import { getApiVersionUrl } from './get-api-version-url';

describe('getApiVersionUrl', () => {
it('keeps the upstream commit link behavior by default', () => {
expect(getApiVersionUrl('v11.2.3.+commit.f64bbacb')).toBe(
'https://github.com/blockscout/blockscout/commit/f64bbacb',
);
});

it('keeps the upstream tree link behavior by default', () => {
expect(getApiVersionUrl('v11.2.3')).toBe(
'https://github.com/blockscout/blockscout/tree/v11.2.3',
);
});

it('builds a release link for a custom repository and strips commit metadata', () => {
expect(getApiVersionUrl(
'v11.2.3.+commit.f64bbacb',
'https://github.com/DOS/DOScan/',
'release',
)).toBe('https://github.com/DOS/DOScan/releases/tag/v11.2.3');
});

it('returns undefined when the version is missing', () => {
expect(getApiVersionUrl(undefined)).toBeUndefined();
});
});
17 changes: 14 additions & 3 deletions src/shell/footer/get-api-version-url.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
// SPDX-License-Identifier: LicenseRef-Blockscout

export function getApiVersionUrl(version: string | undefined): string | undefined {
type VersionLinkType = 'release' | 'tree';

export function getApiVersionUrl(
version: string | undefined,
repoUrl = 'https://github.com/blockscout/blockscout',
linkType: VersionLinkType = 'tree',
): string | undefined {
if (!version) {
return;
}

const [ tag, commit ] = version.split('.+commit.');
const normalizedRepoUrl = repoUrl.replace(/\/+$/, '');

if (linkType === 'release') {
return `${ normalizedRepoUrl }/releases/tag/${ tag }`;
}

if (commit) {
return `https://github.com/blockscout/blockscout/commit/${ commit }`;
return `${ normalizedRepoUrl }/commit/${ commit }`;
}

return `https://github.com/blockscout/blockscout/tree/${ tag }`;
return `${ normalizedRepoUrl }/tree/${ tag }`;
}
Loading