Skip to content

Commit

Permalink
feat: harden internals (#952)
Browse files Browse the repository at this point in the history
* ci: repair jobs

* ci: remove debug version bump

* ci: specify exact fdp-play version

* feat: harden internals

* style: add newline

* build: remove unnecessary dependencies
  • Loading branch information
Cafe137 authored Sep 19, 2024
1 parent 49cacfc commit a640272
Show file tree
Hide file tree
Showing 63 changed files with 6,927 additions and 4,395 deletions.
4 changes: 3 additions & 1 deletion .depcheckrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"husky",
"ts-node",
"webpack-cli",
"playwright-test"
"playwright-test",
"@types/jest",
"ts-jest"
]
}
2 changes: 0 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ on:
env:
BEE_API_URL: 'http://127.0.0.1:1633'
BEE_PEER_API_URL: 'http://127.0.0.1:11633'
BEE_DEBUG_API_URL: 'http://127.0.0.1:1635'
BEE_PEER_DEBUG_API_URL: 'http://127.0.0.1:11635'
BEE_TEST_CHEQUEBOOK: true

jobs:
Expand Down
34 changes: 9 additions & 25 deletions .github/workflows/update_bee.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ on:
repository_dispatch:
types: [update-bee]


jobs:
create-api-docs-pr:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -57,13 +56,6 @@ jobs:
field: engines.beeApiVersion
value: ${{ env.API_VERSION }}

- name: Replace Debug API version in package.json
uses: jossef/action-set-json-field@v1
with:
file: package.json
field: engines.beeDebugApiVersion
value: ${{ env.DEBUG_API_VERSION }}

- name: Add trailing new-line to package.json
run: printf "\n" >> package.json

Expand All @@ -72,30 +64,22 @@ jobs:
with:
find: "export const SUPPORTED_BEE_VERSION_EXACT = '.*?'"
replace: "export const SUPPORTED_BEE_VERSION_EXACT = '${{ env.BEE_VERSION_WITH_COMMIT }}'"
include: "src/modules/debug/status.ts"
include: 'src/modules/debug/status.ts'
regex: true

- name: Replace SUPPORTED_API_VERSION for Status module
uses: jacobtomlinson/gha-find-replace@v2
with:
find: "export const SUPPORTED_API_VERSION = '.*?'"
replace: "export const SUPPORTED_API_VERSION = '${{ env.API_VERSION }}'"
include: "src/modules/debug/status.ts"
regex: true

- name: Replace SUPPORTED_DEBUG_API_VERSION for Status module
uses: jacobtomlinson/gha-find-replace@v2
with:
find: "export const SUPPORTED_DEBUG_API_VERSION = '.*?'"
replace: "export const SUPPORTED_DEBUG_API_VERSION = '${{ env.DEBUG_API_VERSION }}'"
include: "src/modules/debug/status.ts"
include: 'src/modules/debug/status.ts'
regex: true

- name: Replace README version
uses: jacobtomlinson/gha-find-replace@v2
with:
find: "<!-- SUPPORTED_BEE_START -->.*?<!-- SUPPORTED_BEE_END -->"
replace: "<!-- SUPPORTED_BEE_START -->${{ env.FINAL_CLEAN_BEE_VERSION }}<!-- SUPPORTED_BEE_END -->"
find: '<!-- SUPPORTED_BEE_START -->.*?<!-- SUPPORTED_BEE_END -->'
replace: '<!-- SUPPORTED_BEE_START -->${{ env.FINAL_CLEAN_BEE_VERSION }}<!-- SUPPORTED_BEE_END -->'
include: README.md
regex: true

Expand All @@ -105,11 +89,11 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.REPO_GHA_PAT }}
with:
title: "chore: update to bee ${{ env.FINAL_CLEAN_BEE_VERSION }}"
body: "Updated Bee version ${{ env.BEE_VERSION_WITH_COMMIT }}"
branch: "bee-${{ env.FINAL_CLEAN_BEE_VERSION }}"
commit-message: "chore: update to bee"
author: "bee-worker <[email protected]>"
title: 'chore: update to bee ${{ env.FINAL_CLEAN_BEE_VERSION }}'
body: 'Updated Bee version ${{ env.BEE_VERSION_WITH_COMMIT }}'
branch: 'bee-${{ env.FINAL_CLEAN_BEE_VERSION }}'
commit-message: 'chore: update to bee'
author: 'bee-worker <[email protected]>'

- uses: joutvhu/get-release@v1
id: release-notes
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ node_modules
docs

*.shape
shaper.ts
shaper.ts

test/primitives/32mb.bin
88 changes: 88 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/en/configuration.html
*/
import type { Config } from '@jest/types'
import { BeeRequestOptions } from './src'
import { createPostageBatch } from './src/modules/debug/stamps'

import { DEFAULT_BATCH_AMOUNT } from './test/utils'

export default async (): Promise<Config.InitialOptions> => {
try {
const beeRequestOptions: BeeRequestOptions = {
baseURL: process.env.BEE_API_URL || 'http://127.0.0.1:1633/',
timeout: false,
}
const beePeerRequestOptions: BeeRequestOptions = {
baseURL: process.env.BEE_PEER_API_URL || 'http://127.0.0.1:11633/',
timeout: false,
}

if (!process.env.BEE_POSTAGE || !process.env.BEE_PEER_POSTAGE) {
console.log('Creating postage stamps...')

const stampsOrder: { requestOptions: BeeRequestOptions; env: string }[] = []

if (!process.env.BEE_POSTAGE) {
stampsOrder.push({ requestOptions: beeRequestOptions, env: 'BEE_POSTAGE' })
}

if (!process.env.BEE_PEER_POSTAGE) {
stampsOrder.push({ requestOptions: beePeerRequestOptions, env: 'BEE_PEER_POSTAGE' })
}

const stamps = await Promise.all(
stampsOrder.map(async order =>
createPostageBatch(order.requestOptions, DEFAULT_BATCH_AMOUNT, 20, {
waitForUsable: true,
}),
),
)

for (let i = 0; i < stamps.length; i++) {
process.env[stampsOrder[i].env] = stamps[i]
console.log(`${stampsOrder[i].env}: ${stamps[i]}`)
}

console.log('Waiting for the stamps to be usable')
}
} catch (e) {
// It is possible that for unit tests the Bee nodes does not run
// so we are only logging errors and not leaving them to propagate
console.error(e)
}

return {
// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,

// The directory where Jest should output its coverage files
coverageDirectory: 'coverage',

// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: ['/node_modules/'],

// An array of directory names to be searched recursively up from the requiring module's location
moduleDirectories: ['node_modules'],

// Run tests from one or more projects
projects: [
{
preset: 'ts-jest',
displayName: 'node',
testEnvironment: 'node',
testRegex: 'test/.*\\.spec\\.ts',
},
] as unknown[] as string[], // bad types

// The root directory that Jest should scan for tests and modules within
rootDir: 'test',

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: ['/node_modules/'],

// Increase timeout since we have long running cryptographic functions
testTimeout: 4 * 60 * 1000,
}
}
Loading

0 comments on commit a640272

Please sign in to comment.