Skip to content

Commit

Permalink
Make draft pr condition
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Sep 18, 2024
1 parent aa7d382 commit b23d8dd
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 68 deletions.
94 changes: 71 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ on:
env:
DFX_VERSION: 0.22.0
NODE_VERSION: 20
IS_MAIN_BRANCH: ${{ github.ref == 'refs/heads/main' }}
IS_RELEASE_BRANCH_PR: ${{ startsWith(github.head_ref, 'release--') }}
IS_FEATURE_BRANCH_PR: ${{ !startsWith(github.head_ref, 'release--') }}
AZLE_IS_MAIN_BRANCH_PUSH: ${{ github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'demergent-labs/release--') }}
AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH: ${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'demergent-labs/release--') }}
AZLE_IS_RELEASE_BRANCH_PR: ${{ startsWith(github.head_ref, 'release--') }}
AZLE_IS_FEATURE_BRANCH_PR: ${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == false }}
AZLE_IS_FEATURE_BRANCH_DRAFT_PR: ${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == true }}
jobs:
determine-should-run-tests:
name: Determine if tests should run
Expand All @@ -38,24 +40,68 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set exclude dirs
id: set-exclude-dirs
run: |
EXCLUDE_DIRS=""
RELEASE_TESTS="${{ format('
tests/end_to_end/candid_rpc/class_syntax/new/
tests/end_to_end/http_server/new/
') }}"
UNSTABLE_TESTS="${{ format('
examples/basic_bitcoin
examples/bitcoin_psbt
examples/ckbtc
tests/end_to_end/http_server/ethers_base
tests/end_to_end/http_server/http_outcall_fetch
tests/end_to_end/http_server/ic_evm_rpc
tests/property/candid_rpc/class_api/stable_b_tree_map
tests/property/candid_rpc/functional_api/stable_b_tree_map
') }}"
SLOW_TESTS="${{ format('
tests/end_to_end/candid_rpc/functional_syntax/ckbtc
tests/end_to_end/candid_rpc/class_syntax/bitcoin
tests/end_to_end/http_server/large_files
tests/end_to_end/http_server/open_value_sharing
tests/end_to_end/candid_rpc/class_syntax/stable_structures
tests/end_to_end/candid_rpc/functional_syntax/bitcoin
tests/end_to_end/candid_rpc/functional_syntax/composite_queries
tests/end_to_end/candid_rpc/functional_syntax/cross_canister_calls
tests/end_to_end/candid_rpc/functional_syntax/management_canister
tests/end_to_end/candid_rpc/functional_syntax/stable_structures
tests/end_to_end/http_server/autoreload
') }}"
# Exclude RELEASE_TESTS if it's not a release pr
if [[ "${{ env.AZLE_IS_RELEASE_BRANCH_PR}}" == "false" ]]; then
EXCLUDE_DIRS="$EXCLUDE_DIRS $RELEASE_TESTS"
fi
# Exclude UNSTABLE_TESTS if it's a feature branch PR or a feature branch draft pr
if [[ "${{ env.AZLE_IS_FEATURE_BRANCH_PR }}" == "true" || "${{ env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR }}" == "true" ]]; then
EXCLUDE_DIRS="$EXCLUDE_DIRS $UNSTABLE_TESTS"
fi
# Exclude SLOW_TESTS if it's a feature draft PR
if [[ "${{ env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR }}" == "true" ]]; then
EXCLUDE_DIRS="$EXCLUDE_DIRS $SLOW_TESTS"
fi
# Trim leading or trailing spaces and save the exclude-dirs in the environment
EXCLUDE_DIRS=$(echo $EXCLUDE_DIRS | xargs)
echo "exclude-dirs=$EXCLUDE_DIRS" >> $GITHUB_OUTPUT
- name: Get test infos
id: get-test-infos
uses: ./.github/actions/get_test_infos
with:
directories: |
./examples
./tests
exclude-dirs: |
${{ env.IS_FEATURE_BRANCH_PR == 'true' && format('
examples/basic_bitcoin
examples/bitcoin_psbt
examples/ckbtc
tests/end_to_end/http_server/ethers_base
tests/end_to_end/http_server/http_outcall_fetch
tests/end_to_end/http_server/ic_evm_rpc
tests/property/candid_rpc/class_api/stable_b_tree_map
tests/property/candid_rpc/functional_api/stable_b_tree_map
') || '' }}
exclude-dirs: ${{ steps.set-exclude-dirs.outputs.exclude-dirs }}

run-test:
name: '${{matrix.tests.name}} | ${{matrix.tests.displayPath}} | ${{matrix.azle_source}}'
Expand All @@ -68,7 +114,6 @@ jobs:
ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }}
AZLE_IDENTITY_STORAGE_MODE: 'plaintext'
AZLE_END_TO_END_TEST_LINK_AZLE: ${{ matrix.azle_source == 'repo' }}
AZLE_TEST_RUN_ON_RELEASE: ${{ startsWith(github.head_ref, 'release--') }}
strategy:
fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest
matrix: # spins up one job per combination of test and code source (repo or npm).
Expand Down Expand Up @@ -132,27 +177,30 @@ jobs:
shell: bash -l {0}

- name: Start dfx without artificial delay
if: ${{ env.IS_FEATURE_BRANCH_PR == 'true' }}
if: ${{ env.AZLE_IS_FEATURE_BRANCH_PR == 'true' || env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR}}
working-directory: ${{ matrix.tests.path }}
run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0

- name: Start dfx
if: ${{ env.IS_RELEASE_BRANCH_PR == 'true' }}
if: ${{ env.AZLE_IS_RELEASE_BRANCH_PR == 'true' || env.AZLE_IS_MAIN_BRANCH_PUSH == 'true' || env.AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH == 'true' }}
working-directory: ${{ matrix.tests.path }}
run: dfx start --clean --background --host 127.0.0.1:8000

- name: Run test
run: |
IS_MERGE_TO_MAIN_FROM_RELEASE=${{ env.IS_MAIN_BRANCH == 'true' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--') }}
IS_RELEASE_BRANCH_PR_BEFORE_MERGE_TO_MAIN=${{ env.IS_RELEASE_BRANCH_PR == 'true' && env.IS_MAIN_BRANCH == 'false' }}
RUNS=5
if $IS_MERGE_TO_MAIN_FROM_RELEASE; then
RUNS=1
if ${{ env.AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH }}; then
RUNS=100
fi
if $IS_RELEASE_BRANCH_PR_BEFORE_MERGE_TO_MAIN; then
if ${{ env.AZLE_IS_MAIN_BRANCH_PUSH }}; then
RUNS=100
fi
if ${{ env.AZLE_IS_RELEASE_BRANCH_PR }}; then
RUNS=10
fi
if ${{ env.AZLE_IS_FEATURE_BRANCH_PR }}; then
RUNS=5
fi
AZLE_PROPTEST_NUM_RUNS=$RUNS AZLE_PROPTEST_VERBOSE=true npm test
shell: bash -l {0}
Expand Down
2 changes: 1 addition & 1 deletion tests/end_to_end/candid_rpc/class_syntax/new/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "new_end_to_end_test_functional_syntax",
"scripts": {
"test": "if [ \"$AZLE_TEST_RUN_ON_RELEASE\" = \"true\" ]; then tsx test/test.ts; else echo 'Skipping pretests'; fi"
"test": "tsx test/test.ts"
},
"devDependencies": {
"@dfinity/agent": "^0.19.2",
Expand Down
10 changes: 5 additions & 5 deletions tests/end_to_end/http_server/large_files/test/auto_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ const autoGenAutoUploadSmallFileInfos: [number, Unit][] = [
];

const autoGenAutoUploadFileInfos: [number, Unit][] =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? [
process.env.AZLE_IS_FEATURE_BRANCH_PR === 'true' ||
process.env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR === 'true'
? autoGenAutoUploadSmallFileInfos
: [
...autoGenAutoUploadSmallFileInfos,
// General Cases
[1, 'MiB'],
Expand All @@ -31,8 +32,7 @@ const autoGenAutoUploadFileInfos: [number, Unit][] =
// Edge Cases
[2_000_000 + 1, 'B'], // One more byte that the message chunk size
[120 * 1024 * 1024 + 1, 'B'] // One more byte than can be processed in a single hash_file_by_parts call
]
: autoGenAutoUploadSmallFileInfos;
];

const permanentFiles: string[] = [
'photos/people/george-washington.tif',
Expand Down
10 changes: 5 additions & 5 deletions tests/end_to_end/http_server/large_files/test/huge_file_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { Unit } from '../../../../../scripts/file_generator';
import { generateTestFileOfSize } from './generate_test_files';
import { getAutoGeneratedFileName, verifyUpload } from './tests';

const hugeAutoGenAutoUploadSmallFileInfos: [number, Unit][] = [[0, 'GiB']]; // The tests will fail if this array is empty, so for !AZLE_TEST_RUN_ON_RELEASE && !AZLE_TEST_RUN_ON_LOCAL we will have a dummy entry
const hugeAutoGenAutoUploadSmallFileInfos: [number, Unit][] = [[0, 'GiB']]; // The tests will fail if this array is empty, so for AZLE_IS_FEATURE_BRANCH_PR && AZLE_IS_FEATURE_BRANCH_DRAFT_PR we will have a dummy entry

const hugeAutoGenAutoUploadFileInfos: [number, Unit][] =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? [...hugeAutoGenAutoUploadSmallFileInfos, [2, 'GiB']] // TODO add tests for 5GiB and maybe larger https://github.com/demergent-labs/azle/issues/2065
: hugeAutoGenAutoUploadSmallFileInfos;
process.env.AZLE_IS_FEATURE_BRANCH_PR === 'true' ||
process.env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR === 'true'
? hugeAutoGenAutoUploadSmallFileInfos
: [...hugeAutoGenAutoUploadSmallFileInfos, [2, 'GiB']]; // TODO add tests for 5GiB and maybe larger https://github.com/demergent-labs/azle/issues/2065

export function hugeFilesTests(origin: string): Test {
return () => {
Expand Down
8 changes: 4 additions & 4 deletions tests/end_to_end/http_server/large_files/test/manual_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { getAutoGeneratedFileName, verifyUpload } from './tests';

export function manualTests(origin: string): Test {
const manualFileSize =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? 150
: 7;
process.env.AZLE_IS_FEATURE_BRANCH_PR === 'true' ||
process.env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR === 'true'
? 7
: 150;
const autoGenManualUploadFileInfos: [number, Unit][] = [
[manualFileSize, 'MiB']
];
Expand Down
8 changes: 4 additions & 4 deletions tests/end_to_end/http_server/large_files/test/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { manualTests } from './manual_tests';
export function getTests(canisterId: string): Test {
const origin = `http://${canisterId}.localhost:8000`;
const describeLongTest =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? describe
: describe.skip;
process.env.AZLE_IS_FEATURE_BRANCH_PR === 'true' ||
process.env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR === 'true'
? describe.skip
: describe;

return () => {
beforeAll(async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/end_to_end/http_server/new/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scripts": {
"test": "if [ \"$AZLE_TEST_RUN_ON_RELEASE\" = \"true\" ]; then tsx test/test.ts; else echo 'Skipping pretests'; fi"
"test": "tsx test/test.ts"
},
"devDependencies": {
"@dfinity/agent": "^0.19.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const HeterogeneousUpdateMethodArb = UpdateMethodArb(
);

const arrayConstraints =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? defaultArrayConstraints
: shortArrayConstraints;
process.env.AZLE_IS_FEATURE_BRANCH_PR === 'true' ||
process.env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR === 'true'
? shortArrayConstraints
: defaultArrayConstraints;

const CanisterConfigArb = fc
.array(HeterogeneousUpdateMethodArb, arrayConstraints)
Expand Down
8 changes: 4 additions & 4 deletions tests/property/candid_rpc/class_api/recursive/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ const AllRecursiveQueryMethodArb = fc.oneof(
);

const arrayConstraints =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? defaultArrayConstraints
: shortArrayConstraints;
process.env.AZLE_IS_FEATURE_BRANCH_PR === 'true' ||
process.env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR === 'true'
? shortArrayConstraints
: defaultArrayConstraints;

const CanisterConfigArb = fc
.array(AllRecursiveQueryMethodArb, arrayConstraints)
Expand Down
10 changes: 5 additions & 5 deletions tests/property/candid_rpc/class_api/service/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ const AllServicesQueryMethodArb = QueryMethodArb(
);

const arrayConstraints =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? {
process.env.AZLE_IS_FEATURE_BRANCH_PR === 'true' ||
process.env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR === 'true'
? shortArrayConstraints
: {
...defaultArrayConstraints,
maxLength: 30 // If the number of generated services is too large we will run out of space in the wasm custom section.
}
: shortArrayConstraints;
};

const CanisterConfigArb = fc
.array(AllServicesQueryMethodArb, arrayConstraints)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const HeterogeneousUpdateMethodArb = UpdateMethodArb(
);

const arrayConstraints =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? defaultArrayConstraints
: shortArrayConstraints;
process.env.AZLE_IS_FEATURE_BRANCH_PR === 'true' ||
process.env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR === 'true'
? shortArrayConstraints
: defaultArrayConstraints;

const CanisterConfigArb = fc
.array(HeterogeneousUpdateMethodArb, arrayConstraints)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ const AllRecursiveQueryMethodArb = fc.oneof(
);

const arrayConstraints =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? defaultArrayConstraints
: shortArrayConstraints;
process.env.AZLE_IS_FEATURE_BRANCH_PR === 'true' ||
process.env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR === 'true'
? shortArrayConstraints
: defaultArrayConstraints;

const CanisterConfigArb = fc
.array(AllRecursiveQueryMethodArb, arrayConstraints)
Expand Down
8 changes: 4 additions & 4 deletions tests/property/ic_api/chunk/test/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import fc from 'fast-check';
import { _SERVICE as Actor } from './dfx_generated/canister/canister.did';

const max =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? 200
: 80;
process.env.AZLE_IS_FEATURE_BRANCH_PR === 'true' ||
process.env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR === 'true'
? 80
: 200;

// Currently the instruction limit of 40_000_000_000 is hit at about 18_750_000 loops
// So we are rounding up a bit and using 20_000_000 loops to ensure that the instruction limit is hit
Expand Down

0 comments on commit b23d8dd

Please sign in to comment.