Skip to content
Closed
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
8 changes: 0 additions & 8 deletions .claude/settings.local.json

This file was deleted.

53 changes: 1 addition & 52 deletions .github/workflows/ci-failure-email.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jobs:
ACTOR: ${{ github.event.workflow_run.actor.login }}
RUN_URL: ${{ github.event.workflow_run.html_url }}
run: |
reported_at="$(TZ=Asia/Shanghai date '+%Y-%m-%d %H:%M:%S %z')"
issue_title_prefix="[CI failed] $REPOSITORY / $WORKFLOW_NAME at "
body_file="$(mktemp)"
cat > "$body_file" <<EOF
@sunnylqm CI run failed.
Expand All @@ -40,59 +38,10 @@ jobs:
Branch: $HEAD_BRANCH
Commit: $HEAD_SHA
Actor: $ACTOR
Reported at: $reported_at
Run: $RUN_URL
EOF

gh issue create \
--repo "$REPOSITORY" \
--title "$issue_title_prefix$reported_at" \
--title "[CI failed] $REPOSITORY / $WORKFLOW_NAME" \
--body-file "$body_file"

close:
if: github.event.workflow_run.conclusion == 'success'
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- name: Close recovered failure issues
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.repository }}
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
RUN_URL: ${{ github.event.workflow_run.html_url }}
run: |
issue_title_prefix="[CI failed] $REPOSITORY / $WORKFLOW_NAME at "
fixed_at="$(TZ=Asia/Shanghai date '+%Y-%m-%d %H:%M:%S %z')"
issue_numbers="$(
gh issue list \
--repo "$REPOSITORY" \
--state open \
--limit 1000 \
--json number,title |
jq -r --arg prefix "$issue_title_prefix" '.[] | select(.title | startswith($prefix)) | .number'
)"

if [ -z "$issue_numbers" ]; then
exit 0
fi

comment_body="$(cat <<EOF
CI recovered at $fixed_at.

Repository: $REPOSITORY
Workflow: $WORKFLOW_NAME
Branch: $HEAD_BRANCH
Commit: $HEAD_SHA
Run: $RUN_URL
EOF
)"

while IFS= read -r issue_number; do
[ -n "$issue_number" ] || continue
gh issue close "$issue_number" \
--repo "$REPOSITORY" \
--comment "$comment_body"
done <<< "$issue_numbers"
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
import { describe, beforeAll, it, expect } from '@ohos/hypium';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { abilityDelegatorRegistry } from '@kit.TestKit';

const TAG = 'AbilityTest';
const delegator = abilityDelegatorRegistry.getAbilityDelegator();
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';

export default function abilityTest() {
describe('AbilityLaunchTest', () => {
beforeAll(async () => {
hilog.info(0x0000, TAG, 'AbilityLaunchTest beforeAll');
const want = {
bundleName: 'com.example.harmony_use_pushy',
abilityName: 'EntryAbility',
};
await delegator.startAbility(want);
// Allow the RN surface time to initialize
await new Promise<void>(resolve => setTimeout(resolve, 3000));
});

it('ability should launch successfully', 0, async () => {
hilog.info(0x0000, TAG, 'checking ability launch');
const currentAbility = delegator.getCurrentTopAbility();
expect(currentAbility).assertNotNull();
hilog.info(0x0000, TAG, 'ability launched: %{public}s', JSON.stringify(currentAbility.context?.abilityInfo?.name));
});

it('ability context should have valid filesDir', 0, async () => {
const currentAbility = delegator.getCurrentTopAbility();
const context = currentAbility.context;
expect(context).assertNotNull();
expect(context.filesDir).assertContain('/files');
hilog.info(0x0000, TAG, 'filesDir: %{public}s', context.filesDir);
});
});
}
describe('ActsAbilityTest', () => {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
})
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
})
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
})
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
})
it('assertContain', 0, () => {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
let a = 'abc';
let b = 'b';
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b);
expect(a).assertEqual(a);
})
})
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import abilityTest from './Ability.test';
import pushyIntegrationTest from './PushyIntegration.test';

export default function testsuite() {
abilityTest();
pushyIntegrationTest();
}
}

This file was deleted.

50 changes: 26 additions & 24 deletions Example/harmony_use_pushy/harmony/entry/src/test/LocalUnit.test.ets
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
import { describe, it, expect } from '@ohos/hypium';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';

export default function localUnitTest() {
describe('localUnitTest', () => {
it('JSON parse round-trip for update manifest', 0, () => {
const manifest = {
copies: { 'assets/icon.png': 'assets/original.png' },
deletes: ['assets/old.png'],
};
const serialized = JSON.stringify(manifest);
const parsed = JSON.parse(serialized);
expect(parsed.copies['assets/icon.png']).assertEqual('assets/original.png');
expect(parsed.deletes[0]).assertEqual('assets/old.png');
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
});

it('version string comparison works correctly', 0, () => {
const v1 = '1.0.0';
const v2 = '1.0.0';
const v3 = '2.0.0';
expect(v1 === v2).assertEqual(true);
expect(v1 === v3).assertEqual(false);
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
});

it('hash string concatenation for kv keys', 0, () => {
const hash = 'abc123';
const key = `hash_${hash}`;
expect(key).assertEqual('hash_abc123');
expect(key).assertContain('hash_');
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
});
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
});
it('assertContain', 0, () => {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let a = 'abc';
let b = 'b';
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b);
expect(a).assertEqual(a);
});
});
}
}
Loading