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 0.24.2 rc.4 #2093

Closed
wants to merge 104 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
5ecc634
put service tests in the right place
bdemann Aug 26, 2024
c30880a
try setting name
bdemann Aug 26, 2024
b683952
first pass
bdemann Aug 27, 2024
a7f3854
limit to npm packages
bdemann Aug 27, 2024
4ae2ebd
restrict to npm packages
bdemann Aug 27, 2024
b7e5ed1
add exclusions
bdemann Aug 27, 2024
6657880
alphabetize
bdemann Aug 27, 2024
181eabc
update to json
bdemann Aug 27, 2024
0a48161
limit to only packages that have tests
bdemann Aug 27, 2024
9322394
test new auto generated tests
bdemann Aug 27, 2024
7e2adee
hook into real tests
bdemann Aug 28, 2024
f78eccb
update publish-github-actions
bdemann Aug 28, 2024
174bb65
move should run tests to it's own job
bdemann Aug 28, 2024
27dce50
clean up
bdemann Aug 28, 2024
21748da
make num runs a variable
bdemann Aug 28, 2024
fd4b9c0
join similar command into one job
bdemann Aug 28, 2024
5f1de50
move generate-tests script
bdemann Aug 28, 2024
57031d1
update to variables
bdemann Aug 28, 2024
e03f5ac
add report of full path of tests just incase it isn't obvious from th…
bdemann Aug 28, 2024
45273a6
update yml to use new outputs
bdemann Aug 28, 2024
8127bd4
move out conditionals to top levels
bdemann Aug 28, 2024
1b24bb6
get rid of artificial delay for feature prs
bdemann Aug 29, 2024
2c51bba
move versions to env variables
bdemann Aug 29, 2024
e76c4fe
create custom action for finding test dirs
bdemann Aug 29, 2024
2434e2a
first pass at build job
bdemann Aug 29, 2024
6a1993c
move build to it's own workflow
bdemann Aug 29, 2024
35954b9
file clean up
bdemann Aug 29, 2024
45c87d7
try object filtering
bdemann Aug 29, 2024
3593238
pr fixes
bdemann Aug 29, 2024
2a2d8c0
pr fixes
bdemann Aug 29, 2024
006a615
better wording in action
bdemann Aug 29, 2024
96a37f5
naming updates
bdemann Aug 29, 2024
d95051f
get rid of unused var
bdemann Aug 29, 2024
fe2c5a6
pr fixes
bdemann Aug 29, 2024
3ff7ef1
make sure empty all_directories leads to empty result
bdemann Aug 30, 2024
c410511
fix capitalization
bdemann Aug 30, 2024
c304651
rename generate_tests
bdemann Aug 30, 2024
b4e9f2c
variable clean up
bdemann Aug 30, 2024
8e3dac1
test commit message
bdemann Aug 30, 2024
c64698c
Merge branch 'main' into update_github_workflows
bdemann Aug 30, 2024
e86a157
pr fixes
bdemann Aug 30, 2024
3772934
rename build workflow
bdemann Aug 30, 2024
e758108
rename to release candidate deploy
bdemann Aug 30, 2024
a98b9ca
move should release to it's own action
bdemann Aug 30, 2024
4fc4061
clean up and stabilize should run action
bdemann Aug 30, 2024
e86715e
pr fixes
bdemann Aug 30, 2024
bc5b666
simplify logic for num runs
bdemann Aug 30, 2024
0e319a4
move configurable options to the top of the env
bdemann Aug 30, 2024
50f898c
update env logic
bdemann Aug 30, 2024
34c93b7
fix logic
bdemann Aug 29, 2024
0378e9b
Merge branch 'main' into update_github_workflows
bdemann Sep 5, 2024
ffdbf70
add ref to checkout
bdemann Sep 5, 2024
660984d
checkout outputs
bdemann Sep 5, 2024
7a6828f
use javascript for json generation
bdemann Sep 6, 2024
6346ba4
only run get_tests if the tests or release should run
bdemann Sep 6, 2024
fa7a066
Merge branch 'main' into update_github_workflows
bdemann Sep 6, 2024
6ab44e4
Merge branch 'main' into update_github_workflows
bdemann Sep 11, 2024
a248d31
build the binaries on release
bdemann Sep 11, 2024
a18a0a1
Merge branch 'main' into update_github_workflows
bdemann Sep 12, 2024
4d8c1b9
make sure rust is installed for release
bdemann Sep 12, 2024
facf4f5
update path to install rust script
bdemann Sep 12, 2024
4124ad0
add installation for was2ic
bdemann Sep 12, 2024
bf92722
add wasm32-wasi target
bdemann Sep 12, 2024
99b7216
better logging
bdemann Sep 12, 2024
b5cf3bc
rename install script
bdemann Sep 12, 2024
a1a7cab
update to be more immutable
bdemann Sep 12, 2024
338c6ab
update logic
bdemann Sep 12, 2024
ef1c12f
pr fixes
bdemann Sep 12, 2024
29221ef
change contains to startsWith were appropriate
bdemann Sep 12, 2024
3d937eb
rename get-tests to get-test-infos
bdemann Sep 12, 2024
d5d468c
shorten to infos
bdemann Sep 12, 2024
c020876
update all underscores to hyphens
bdemann Sep 12, 2024
db99a50
pr fix
bdemann Sep 12, 2024
f5069c3
naming fixes
bdemann Sep 12, 2024
c13d534
more naming fixes
bdemann Sep 12, 2024
99f3a11
even more naming fixes
bdemann Sep 12, 2024
3c1b9d3
more naming fixes
bdemann Sep 12, 2024
665055e
more naming fixes
bdemann Sep 12, 2024
7340ecc
a fix for jordan
bdemann Sep 12, 2024
c2025ee
more renaming
bdemann Sep 12, 2024
71a6066
even more naming fixes
bdemann Sep 12, 2024
743d2d7
final naming fix
bdemann Sep 12, 2024
4650d96
matrix variables should use underscores
bdemann Sep 12, 2024
e492358
tests update package locks
bdemann Sep 13, 2024
8268385
update async_async functional as well
bdemann Sep 13, 2024
d08bb16
update package-locks
bdemann Sep 13, 2024
fe06161
pr fix
bdemann Sep 13, 2024
9accf68
update package locks
bdemann Sep 13, 2024
fa16212
easy pr fixes
bdemann Sep 13, 2024
deed6f5
move more functionality to js
bdemann Sep 13, 2024
7e40de5
fix filtering error
bdemann Sep 13, 2024
e415f49
better naming
bdemann Sep 13, 2024
442dea9
update test names
bdemann Sep 13, 2024
aaeb507
put the dirs back
bdemann Sep 13, 2024
d0efc3e
even more naming fixes
bdemann Sep 13, 2024
747bd20
remove extra dir info
bdemann Sep 13, 2024
e54e8d9
update installation of global dependencies
bdemann Sep 13, 2024
5fad02a
fix examples
bdemann Sep 13, 2024
1ddf55e
don't display type in test name
bdemann Sep 13, 2024
85d76f1
fix description
bdemann Sep 13, 2024
c90f73a
pr fixes
bdemann Sep 16, 2024
87c970e
update to tsx
bdemann Sep 16, 2024
26ca70f
even more name fixing
bdemann Sep 16, 2024
c4dc92f
release--0.24.2-rc.4
bdemann Sep 13, 2024
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
45 changes: 45 additions & 0 deletions .github/actions/get_test_infos/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Get test infos
description:
'Gets a list of test info objects for each npm project with an npm test script
The shape of the object is
{
path: string, // The path to the test
name: string, // The name of the test
type: string, // The type of test (e.g. ex (example), prop (property test), e2e, (end to end test) etc)
displayPath: string // An abbreviated version of the path for display purposes only
}'
inputs:
directories:
description: List of directories to search for npm projects with an npm test script
required: true
exclude-dirs:
description: List of directories to exclude from the search
required: false
default: ''
node-version:
description: The version of Node.js to use
required: true
default: '20.x'
outputs:
test-infos:
description: All of the test info objects found by this action
value: ${{ steps.get-test-infos.outputs.test-infos }}
runs:
using: composite
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}

- name: Get test infos
id: get-test-infos
run: |
# Export the input variables to make them available to the script
export INPUT_DIRECTORIES="${{ inputs.directories }}"
export INPUT_EXCLUDE_DIRS="${{ inputs.exclude-dirs }}"
# Run the script
TEST_INFOS=$(./.github/actions/get_test_infos/get_test_infos.sh | base64 -d)
echo "test-infos=${TEST_INFOS}" >> "$GITHUB_OUTPUT"
shell: bash
48 changes: 48 additions & 0 deletions .github/actions/get_test_infos/dir_to_test_info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { basename } from 'path';

type TestInfo = {
path: string;
name: string;
type: Type;
displayPath: string;
};

type Type = 'ex' | 'e2e' | 'prop' | '';

export function dirToTestInfo(dir: string): TestInfo {
const path = dir;
const name = basename(dir);
const type = getType(dir);
const displayPath = generateDisplayPath(dir);

return { path, name, type, displayPath };
}

function getType(dir: string): Type {
if (dir.includes('examples/')) return 'ex';
if (dir.includes('/end_to_end/')) return 'e2e';
if (dir.includes('/property/')) return 'prop';
return '';
}

function generateDisplayPath(path: string): string {
const replacements = {
examples: 'ex',
property: 'prop',
end_to_end: 'e2e',
functional_syntax: 'func',
functional_api: 'func',
class_syntax: 'class',
class_api: 'class',
candid_rpc: 'crpc',
http_server: 'http',
tests: 't'
};

return path
.split('/')
.map((dir) => {
return replacements[dir] || dir;
})
.join('/');
}
46 changes: 46 additions & 0 deletions .github/actions/get_test_infos/discover_test_dirs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { promises as fs } from 'fs';
import path from 'path';

// Recursively find directories and check for package.json with a test script
export async function discoverTestDirs(dirToSearch: string): Promise<string[]> {
const files = await fs.readdir(dirToSearch, { withFileTypes: true });

return files.reduce(
async (accPromise, file) => {
const acc = await accPromise;

const fullPath = path.join(dirToSearch, file.name);

if (file.isDirectory() && !fullPath.includes('node_modules')) {
// Check for package.json and if it contains a test script
const packageJsonPath = path.join(fullPath, 'package.json');
const hasTestScript = await checkForTestScript(packageJsonPath);

// Recurse into subdirectory
return [
...acc,
...(hasTestScript ? [fullPath] : []),
...(await discoverTestDirs(fullPath))
];
}

return [];
},
Promise.resolve([] as string[])
);
}

// Check if package.json exists and contains a test script
async function checkForTestScript(packageJsonPath: string): Promise<boolean> {
try {
const packageJson = await fs.readFile(packageJsonPath, 'utf-8');
const packageData = JSON.parse(packageJson);
return (
packageData.scripts !== undefined &&
packageData.scripts.test !== undefined
);
} catch {
// Return false if the file doesn't exist or there's a JSON error
return false;
}
}
20 changes: 20 additions & 0 deletions .github/actions/get_test_infos/get_test_infos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Inputs from action.yml or environment variables
DIRECTORIES=($INPUT_DIRECTORIES)
EXCLUDE_DIRS=($INPUT_EXCLUDE_DIRS)

# Convert arrays to comma-separated strings for passing into Node.js
directories=$(IFS=, ; echo "${DIRECTORIES[*]}")
exclude_dirs=$(IFS=, ; echo "${EXCLUDE_DIRS[*]}")

# Get test infos
json_result=$(npx tsx .github/actions/get_test_infos/index.js "$directories" "$exclude_dirs")

# Format the result
result="${json_result//'%'/'%25'}"
result="${result//$'\n'/'%0A'}"
result="${result//$'\r'/'%0D'}"

# Output the final result as base64
echo "$result" | base64
25 changes: 25 additions & 0 deletions .github/actions/get_test_infos/get_test_infos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { discoverTestDirs } from './discover_test_dirs.js';
import { dirToTestInfo } from './dir_to_test_info.js';

export async function getTestInfos(dirs: string[], excludeDirs: string[]) {
const allDirs = (
await dirs.reduce(
async (accPromise, dir) => {
const acc = await accPromise;
const discoveredDirs = await discoverTestDirs(dir);
return [...acc, ...discoveredDirs];
},
Promise.resolve([] as string[])
)
)
.filter((dir) => dir && !isExcluded(dir, excludeDirs))
.sort();

const testInfos = allDirs.map((dir) => dirToTestInfo(dir));

return testInfos;
}

function isExcluded(dir, excludeDirs) {
return excludeDirs.some((exclude) => dir.includes(exclude));
}
20 changes: 20 additions & 0 deletions .github/actions/get_test_infos/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { getTestInfos } from './get_test_infos.js';

// Parse command-line arguments
const [, , dirsArg, excludeDirsArg] = process.argv;

// Convert comma-separated strings to arrays
const dirs = dirsArg.split(',').filter((path) => path !== '');
const excludeDirs = excludeDirsArg.split(',').filter((path) => path !== '');

async function main() {
try {
const result = await getTestInfos(dirs, excludeDirs);
process.stdout.write(JSON.stringify(result));
} catch (error) {
console.error('Error processing directories:', error);
process.exit(1);
}
}

main();
27 changes: 27 additions & 0 deletions .github/actions/should_release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Should release
description: Determines if the current pull request is for testing or for starting a release
outputs:
should-release:
description: Returns true if this branch should start a release, otherwise false
value: ${{ steps.determine-should-release.outputs.should-release }}
runs:
using: composite
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }} # This is necessary for this job to be able to get the correct commit message from `git log`

- id: determine-should-release
run: |
BRANCH_NAME="${{ github.head_ref }}"
RELEASE_VERSION="${BRANCH_NAME:9}"
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
IS_RELEASE_BRANCH_PR="${{ startsWith(github.head_ref, 'release--') }}"

SHOULD_RELEASE="false"
if [[ $IS_RELEASE_BRANCH_PR == "true" && "$COMMIT_MESSAGE" == "release--$RELEASE_VERSION" ]]; then
SHOULD_RELEASE="true"
fi

echo "should-release=${SHOULD_RELEASE}" >> "$GITHUB_OUTPUT"
shell: bash
58 changes: 58 additions & 0 deletions .github/scripts/install_global_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# File path for the global dependencies
GLOBAL_DEPENDENCIES_FILE="$PWD/global_dependencies.json"

# Ensure jq is installed for JSON parsing
if ! command -v jq &> /dev/null; then
echo "jq could not be found. Please install jq to parse JSON."
exit 1
fi

# Extract the rustc version from the JSON file
RUST_VERSION=$(jq -r '.dependencies.rustc // empty' "$GLOBAL_DEPENDENCIES_FILE")

if [[ -z "$RUST_VERSION" ]]; then
echo "Rust version not found in $GLOBAL_DEPENDENCIES_FILE"
exit 1
fi

# Install Rust using rustup with the extracted version
echo "Installing Rust version $RUST_VERSION"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_VERSION"
source $HOME/.cargo/env

rustup target add wasm32-wasi

# Extract the wasi2ic version and repository URL
WASI2IC_VERSION=$(jq -r '.dependencies.wasi2ic // empty' "$GLOBAL_DEPENDENCIES_FILE")

# Determine if WASI2IC_VERSION is a URL (repo) or just a version number
if [[ $WASI2IC_VERSION =~ ^https?:// ]]; then
WASI2IC_URL=$WASI2IC_VERSION
else
WASI2IC_URL=""
fi

if [[ -z "$WASI2IC_VERSION" ]]; then
echo "wasi2ic version not found in $GLOBAL_DEPENDENCIES_FILE"
exit 1
fi

# Install wasi2ic
if [[ -n "$WASI2IC_URL" ]]; then
echo "Installing wasi2ic from repository $WASI2IC_URL"
cargo install --git "$WASI2IC_URL"
else
echo "Installing wasi2ic version $WASI2IC_VERSION"
cargo install wasi2ic --version "$WASI2IC_VERSION"
fi

# Confirm installation
echo "\nThe following global dependencies were installed"
rustc --version
cargo --version

rustup target list --installed | grep wasm32-wasi

cargo install --list | grep wasi2ic
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ VERSION=$1

directories_json_string_with_linebreaks=$2
directories_json_string="${directories_json_string_with_linebreaks//$'\\n'/''}"
directories=$(echo "$directories_json_string" | jq -c -r '.[]')
directories=$(echo "$directories_json_string" | jq -c -r '.[] | .path')

sed -E -i "s/(\"version\": \")(.*)(\")/\1$VERSION\3/" package.json
sed -E -i "s/(\"version\": \")(.*)(\")/\1$VERSION\3/" dfx_extension/extension.json
# TODO we need to keep the dependencies.json file up-to-date as well
npm install

# Build the binary templates
npx azle template
npx azle template --experimental

if [[ "$VERSION" == *"-rc."* ]];
then
npm publish --tag next
Expand Down
Loading
Loading