From bba3ddeef3b877933043b3acaa0b7d68548bd898 Mon Sep 17 00:00:00 2001 From: Wenxi Zeng Date: Fri, 3 May 2024 13:36:41 -0500 Subject: [PATCH] setup ci (#10) Co-authored-by: Wenxi Zeng --- .github/ISSUE_TEMPLATE/bug_report.md | 31 ++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++ .../ISSUE_TEMPLATE/pull_request_template.md | 13 +++ .github/workflows/build.yml | 102 ++++++++++++++++++ .github/workflows/create_jira.yml | 39 +++++++ .github/workflows/release.yml | 54 ++++++++++ .github/workflows/snapshot.yml | 31 ++++++ app/src/main/res/raw/default_liveplugins.js | 2 +- 8 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/pull_request_template.md create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/create_jira.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/snapshot.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..ae1eec4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,31 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: triage +assignees: wenxi-zeng + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Do '...' +2. '....' +3. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Platform (please complete the following information):** + - Library Version in use: [e.g. 0.0.5] + - Platform being tested: [e.g. Android] + - Integrations in use: [e.g. Firebase, Amplitude] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..63670f1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: triage +assignees: prayansh + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/pull_request_template.md b/.github/ISSUE_TEMPLATE/pull_request_template.md new file mode 100644 index 0000000..b971f07 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/pull_request_template.md @@ -0,0 +1,13 @@ +## Purpose +_Describe the problem or feature in addition to a link to the issues._ + +## Approach +_How does this change address the problem?_ + +#### Open Questions and Pre-Merge TODOs +- [ ] Use github checklists. When solved, check the box and explain the answer. + +## Learning +_Describe the research stage_ + +_Links to blog posts, patterns, libraries or addons used to solve this problem_ \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..949592b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,102 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + cancel_previous: + + runs-on: ubuntu-latest + steps: + - uses: styfle/cancel-workflow-action@0.9.1 + with: + workflow_id: ${{ github.event.workflow.id }} + + core-test: + needs: cancel_previous + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: cache gradle dependencies + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-core-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle-core- + - name: Run Tests + run: ./gradlew core:test + - name: Generate coverage report + run: ./gradlew core:codeCoverageReport + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + + android-test: + needs: cancel_previous + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: cache gradle dependencies + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-android-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle-android- + - name: Run Tests + run: ./gradlew android:test + - name: Generate coverage report + run: ./gradlew android:codeCoverageReport + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + + destination-test: + needs: cancel_previous + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: cache gradle dependencies + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-dest-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle-dest- + - name: Run Tests + run: ./gradlew samples:kotlin-android-app-destinations:test + - name: Generate coverage report + run: ./gradlew samples:kotlin-android-app-destinations:codeCoverageReport + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + + security: + needs: cancel_previous + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Snyk + run: ./gradlew snyk-test + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} diff --git a/.github/workflows/create_jira.yml b/.github/workflows/create_jira.yml new file mode 100644 index 0000000..51ba6a8 --- /dev/null +++ b/.github/workflows/create_jira.yml @@ -0,0 +1,39 @@ +name: Create Jira Ticket + +on: + issues: + types: + - opened + +jobs: + create_jira: + name: Create Jira Ticket + runs-on: ubuntu-latest + environment: IssueTracker + steps: + - name: Checkout + uses: actions/checkout@master + - name: Login + uses: atlassian/gajira-login@master + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_TOKEN }} + JIRA_EPIC_KEY: ${{ secrets.JIRA_EPIC_KEY }} + JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }} + + - name: Create + id: create + uses: atlassian/gajira-create@master + with: + project: ${{ secrets.JIRA_PROJECT }} + issuetype: Bug + summary: | + [${{ github.event.repository.name }}] (${{ github.event.issue.number }}): ${{ github.event.issue.title }} + description: | + Github Link: ${{ github.event.issue.html_url }} + ${{ github.event.issue.body }} + fields: '{"parent": {"key": "${{ secrets.JIRA_EPIC_KEY }}"}}' + + - name: Log created issue + run: echo "Issue ${{ steps.create.outputs.issue }} was created" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3cb1068 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: Release + +on: + push: + tags: + - '*.*.*' + +jobs: + release: + runs-on: ubuntu-latest + environment: deployment + steps: + - uses: actions/checkout@v2 + - name: Get tag + id: vars + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + - name: Verify tag + run: | + VERSION=$(grep VERSION_NAME gradle.properties | awk -F= '{ print $2 }' | sed "s/-SNAPSHOT//") + if [ "${{ steps.vars.outputs.tag }}" != "$VERSION" ]; then { + echo "Tag ${{ steps.vars.outputs.tag }} does not match the package version ($VERSION)" + exit 1 + } fi + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: cache gradle dependencies + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-core-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle-core- + - name: Publush release to sonatype + run: ./gradlew clean build publish publishToSonatype -Prelease closeAndReleaseSonatypeStagingRepository + env: + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.NEXUS_USERNAME }} + ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.NEXUS_PASSWORD }} + SIGNING_PRIVATE_KEY_BASE64: ${{ secrets.SIGNING_PRIVATE_KEY_BASE64 }} + + - name: create release + run: | + curl \ + -X POST \ + -H "Authorization: token $RELEASE_TOKEN" \ + https://api.github.com/repos/${{github.repository}}/releases \ + -d '{"tag_name": "${{ env.RELEASE_VERSION }}", "name": "${{ env.RELEASE_VERSION }}", "body": "Release of version ${{ env.RELEASE_VERSION }}", "draft": false, "prerelease": false, "generate_release_notes": true}' + env: + RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} + RELEASE_VERSION: ${{ steps.vars.outputs.tag }} \ No newline at end of file diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 0000000..008582a --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,31 @@ +name: Snapshot + +on: + push: + branches: [ main ] + +jobs: + snapshot: + runs-on: ubuntu-latest + environment: deployment + steps: + - uses: actions/checkout@v2 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: cache gradle dependencies + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-core-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle-core- + - name: Publush snapshot to sonatype + run: ./gradlew clean build publish publishToSonatype + env: + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.NEXUS_USERNAME }} + ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.NEXUS_PASSWORD }} + SIGNING_PRIVATE_KEY_BASE64: ${{ secrets.SIGNING_PRIVATE_KEY_BASE64 }} \ No newline at end of file diff --git a/app/src/main/res/raw/default_liveplugins.js b/app/src/main/res/raw/default_liveplugins.js index 89ee45c..973a684 100644 --- a/app/src/main/res/raw/default_liveplugins.js +++ b/app/src/main/res/raw/default_liveplugins.js @@ -47,7 +47,7 @@ const checkoutEventProps = { amount: "$1337.00" } -let a = new Analytics("s0gnfvAubC5OqMzYEjqdAwLiVSGHmaZy", analytics); +let a = new Analytics("HGSe7bCEnT78Pfc6FEZcylGrl5fqkfcA"); _ = a.track("testtest") _ = a.track("userRegisteredEvent", userRegisteredEventProps); _ = a.track("checkoutEvent", checkoutEventProps);