From b7ba825e972402c35cc5c428fcc347ffaa18a5c1 Mon Sep 17 00:00:00 2001 From: Nagarjun Sanji Date: Mon, 1 Jul 2024 18:21:12 +0530 Subject: [PATCH] Create CI/CD Pipeline for VS Code Extension Project (#4) * Create build.yml * added base template for github workflows * updated workflow * updated ci * updated build stage * yml updated * updated test stage * updated to parallel processing * updated build * updated config file * Cache node_modules * updated bug report image * updated restore key * checking cache * checking cache * checking without cache * with cache * storing in output variable * code updated * final code * removed internal document link * updated workflow - delete cache * pipeline fix * removed gh and used curl in workflow * pipeline fix * pipeline fix * workflow cleanup --------- Co-authored-by: Nagarjun Sanji Co-authored-by: Rajpreet Singh --- .github/ISSUE_TEMPLATE/bug_report.yml | 63 +++++++++++++ .../documentation_improvement.yml | 36 ++++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 45 ++++++++++ .github/ISSUE_TEMPLATE/question.yml | 27 ++++++ .github/pull_request_template.md | 60 +++++++++++++ .github/release_template.md | 48 ++++++++++ .github/workflows/ci.yml | 90 +++++++++++++++++++ .github/workflows/publish.yml | 24 +++++ 8 files changed, 393 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/documentation_improvement.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/ISSUE_TEMPLATE/question.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/release_template.md create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..acaa0c9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,63 @@ +name: 🐞 Bug Report +description: Report a bug in the Debricked VS Code Extension +title: "[BUG] " +labels: [bug] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! Please provide as much detail as possible to help us resolve the issue. + + - type: input + id: environment + attributes: + label: Environment + description: Provide details about your development environment (e.g., operating system, VS Code version). + placeholder: "Windows 10, VS Code 1.55.0" + validations: + required: true + + - type: textarea + id: description + attributes: + label: Description + description: A clear and concise description of what the bug is. + placeholder: "A clear and concise description of what the bug is." + validations: + required: true + + - type: textarea + id: steps + attributes: + label: Steps to Reproduce + description: Steps to reproduce the behavior. + placeholder: "1. Go to '...'\n2. Click on '....'\n3. Scroll down to '....'\n4. See error" + validations: + required: true + + - type: textarea + id: expected + attributes: + label: Expected Behavior + description: A clear and concise description of what you expected to happen. + placeholder: "A clear and concise description of what you expected to happen." + validations: + required: true + + - type: textarea + id: actual + attributes: + label: Actual Behavior + description: A clear and concise description of what actually happened. + placeholder: "A clear and concise description of what actually happened." + validations: + required: true + + - type: textarea + id: screenshots + attributes: + label: Screenshots + description: Add any screenshots that might help explain your problem. + placeholder: "If applicable, add screenshots to help explain your problem." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/documentation_improvement.yml b/.github/ISSUE_TEMPLATE/documentation_improvement.yml new file mode 100644 index 0000000..a8d44e2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation_improvement.yml @@ -0,0 +1,36 @@ +name: 📃 Documentation Improvement +description: Suggest improvements to the documentation for the Debricked VS Code Extension +title: "[DOCS] " +labels: [documentation] +body: + - type: markdown + attributes: + value: | + Thanks for helping us improve our documentation! Please provide as much detail as possible to help us understand your suggestion. + + - type: input + id: title + attributes: + label: Title + description: Provide a title for your documentation improvement suggestion. + placeholder: "Title of your documentation improvement suggestion" + validations: + required: true + + - type: textarea + id: description + attributes: + label: Description + description: A clear and concise description of the documentation improvement. + placeholder: "A clear and concise description of the documentation improvement." + validations: + required: true + + - type: textarea + id: location + attributes: + label: Documentation Location + description: Provide the location (file, section, etc.) of the documentation you suggest improving. + placeholder: "Location of the documentation (file, section, etc.)" + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..8630b3e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,45 @@ +name: 🚀 Feature Request +description: Suggest a new feature for the Debricked VS Code Extension +title: "[FEATURE] " +labels: [enhancement] +body: + - type: markdown + attributes: + value: | + Thanks for suggesting a new feature! Please provide as much detail as possible to help us understand your request. + + - type: input + id: title + attributes: + label: Feature Title + description: Provide a title for your feature request. + placeholder: "Feature title" + validations: + required: true + + - type: textarea + id: description + attributes: + label: Description + description: A clear and concise description of what you want to happen. + placeholder: "A clear and concise description of what you want to happen." + validations: + required: true + + - type: textarea + id: motivation + attributes: + label: Motivation + description: Explain why this feature is important and how it would benefit users. + placeholder: "Why is this feature important? How would it benefit users?" + validations: + required: true + + - type: textarea + id: alternatives + attributes: + label: Alternatives + description: Describe any alternative solutions or features you've considered. + placeholder: "Describe any alternative solutions or features you've considered." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 0000000..a611411 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,27 @@ +name: 🤔 Question or Discussion +description: Ask a question or start a discussion about the Debricked VS Code Extension +title: "[QUESTION] " +labels: [question] +body: + - type: markdown + attributes: + value: | + Thanks for reaching out! Please provide as much detail as possible to help us address your question or discussion topic. + + - type: input + id: title + attributes: + label: Title + description: Provide a title for your question or discussion. + placeholder: "Title of your question or discussion" + validations: + required: true + + - type: textarea + id: description + attributes: + label: Description + description: A clear and concise description of your question or discussion topic. + placeholder: "A clear and concise description of your question or discussion topic." + validations: + required: true diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..8bd2cad --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,60 @@ +## Prerequisites for merge, code author responsibilities +* [ ] I as the code author have ensured that acceptance criteria is met +* [ ] I as the code author have self-reviewed code and functionality +* [ ] I have added new tests/extended existing ones +* [ ] If this contains frontend changes, a design review has been requested and completed +* [ ] A security review is initialized according to Security Chapter Policy + +## Prerequisites for merge, reviewer responsibilities +* [ ] I as the reviewer have ensured that acceptance criteria is met +* [ ] Code has been reviewed +* [ ] Ensured the right tests have been added +* [ ] Manual testing has been performed + +## Description of changes +Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. + +Fixes # (issue) + +## Type of change +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] This change requires a documentation update + +## How Has This Been Tested? +Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. + +### Unit Tests +These are tests that validate the functionality of a specific section of code, usually at the function level. + +- [ ] Test A: Description of unit test A (e.g., "Test to verify that the input validation function correctly identifies invalid inputs") +- [ ] Test B: Description of unit test B (e.g., "Test to ensure the output formatting function produces the correct format for given inputs") + +### Integration Tests +These tests verify the interaction between different pieces of code to ensure they work together as expected. + +- [ ] Test C: Description of integration test C (e.g., "Test to check that the integration between the data processing module and the database module works correctly") +- [ ] Test D: Description of integration test D (e.g., "Test to verify that the API endpoint correctly integrates with the authentication module") + +### End-to-End Tests +These tests simulate real user scenarios to validate the entire application flow. + +- [ ] Test E: Description of end-to-end test E (e.g., "Test to ensure that a user can successfully complete the sign-up process") +- [ ] Test F: Description of end-to-end test F (e.g., "Test to verify that a user can create, update, and delete an item in the application") + +### Manual Tests +These are tests that require a human to interact with the application to verify functionality. + +- [ ] Test G: Description of manual test G (e.g., "Manually test the new feature to ensure it works as expected in the user interface") +- [ ] Test H: Description of manual test H (e.g., "Manually test the bug fix to ensure the issue is resolved and no new issues are introduced") + +## Checklist: +- [ ] My code follows the style guidelines of this project +- [ ] I have performed a self-review of my own code +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] My changes generate no new warnings +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] New and existing unit tests pass locally with my changes +- [ ] Any dependent changes have been merged and published in downstream modules diff --git a/.github/release_template.md b/.github/release_template.md new file mode 100644 index 0000000..52aeac9 --- /dev/null +++ b/.github/release_template.md @@ -0,0 +1,48 @@ +# Release Notes + +## Version {VERSION_NUMBER} - {RELEASE_DATE} + +### Summary +{Brief summary of the release, highlighting the key features and improvements.} + +--- + +### New Features +- {Feature 1: Detailed description of the new feature, how it works, and its benefits.} +- {Feature 2: Detailed description of the new feature, how it works, and its benefits.} +- {Feature 3: Detailed description of the new feature, how it works, and its benefits.} + +### Bug Fixes +- {Fix 1: Description of the bug that was fixed and how it was resolved.} +- {Fix 2: Description of the bug that was fixed and how it was resolved.} +- {Fix 3: Description of the bug that was fixed and how it was resolved.} + +### Improvements +- {Improvement 1: Description of the improvement and its impact.} +- {Improvement 2: Description of the improvement and its impact.} +- {Improvement 3: Description of the improvement and its impact.} + +### Documentation +- {Documentation update 1: Details about any updates made to the documentation.} +- {Documentation update 2: Details about any updates made to the documentation.} + +### Known Issues +- {Issue 1: Description of any known issues that are not resolved in this release.} +- {Issue 2: Description of any known issues that are not resolved in this release.} + +### Contributors +We would like to thank the following contributors for their efforts in this release: +- @{Contributor 1} +- @{Contributor 2} +- @{Contributor 3} + +### Download Links +- [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=debricked) +- [GitHub Releases](https://github.com/debricked/VS-Code-extension/releases) + +### Upgrade Instructions +{Instructions on how to upgrade to this version, if necessary. Include any breaking changes or important notes.} + +--- + +Thank you for using debricked: VS Code extension. If you encounter any issues or have any feedback, please [open an issue](https://github.com/debricked/VS-Code-extension/issues) or [contact support](mailto:support@debricked.com). diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..24bb680 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,90 @@ +name: CI + +on: + push: + branches: ['**'] + pull_request: + branches: [main] + +jobs: + setup: + runs-on: ubuntu-latest + outputs: + package-lock-hash: ${{ runner.os }}-repo-${{ steps.hash.outputs.hash }} + steps: + - uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + - name: Install dependencies + run: npm ci + - name: Calculate package-lock.json hash + id: hash + run: echo "hash=$(sha256sum package-lock.json | awk '{ print $1 }')" >> "$GITHUB_OUTPUT" + - name: Cache repository + uses: actions/cache@v4 + with: + path: . + key: ${{ runner.os }}-repo-${{ steps.hash.outputs.hash }} + + build: + runs-on: ubuntu-latest + needs: setup + steps: + - name: Restore repository cache + uses: actions/cache@v4 + with: + path: . + key: ${{ needs.setup.outputs.package-lock-hash }} + fail-on-cache-miss: true + - name: Compile + run: npm run compile + + test: + runs-on: ubuntu-latest + needs: setup + steps: + - name: Restore repository cache + uses: actions/cache@v4 + with: + path: . + key: ${{ needs.setup.outputs.package-lock-hash }} + fail-on-cache-miss: true + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y libasound2 libgbm1 libgtk-3-0 libnss3 xvfb + - name: Run tests + run: xvfb-run -a npm run test + - name: Upload coverage + uses: actions/upload-artifact@v4 + with: + name: coverage + path: coverage/ + retention-days: 1 + + cleanup: + runs-on: ubuntu-latest + needs: [setup, build, test] + if: always() + steps: + - name: Cleanup + run: npm cache clean --force + - name: Delete GitHub Actions cache + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + CACHE_KEY="${{ needs.setup.outputs.package-lock-hash }}" + + if [ -n "$CACHE_KEY" ]; then + curl -L \ + -X DELETE \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: token $GH_TOKEN" \ + "https://api.github.com/repos/${{ github.repository }}/actions/caches?key=$CACHE_KEY" + + echo "Cache deleted successfully" + else + echo "No matching cache found" + fi \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..2070bb1 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,24 @@ +name: Publish to VS Code MarketPlace + +on: + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v4 + - name: Set up + uses: actions/setup-node@v4 + with: + node-version: '22' + - run: | + npm ci + npm install -g vsce + - name: Package + run: vsce package + - name: Publish + env: + VSCE_PAT: secrets.VSCE_PAT + run: vsce publish -p $VSCE_PAT \ No newline at end of file