Add CI workflow for linting, testing, and building#7
Add CI workflow for linting, testing, and building#7xpertforextradeinc merged 2 commits intomainfrom
Conversation
This workflow runs on pushes and pull requests to the main branch, as well as on a daily schedule. It includes steps for checking out the code, setting up Node.js, installing dependencies, running linting and tests, building the project, and notifying Slack.
There was a problem hiding this comment.
Pull request overview
This PR adds a new GitHub Actions CI workflow that automates linting, testing, building, and Slack notifications for the project. The workflow triggers on pushes/PRs to main and release branches, as well as on a daily schedule at 02:00 UTC.
- Configures automated CI pipeline with lint, test, and build steps
- Sets up Node.js 18 environment with npm caching
- Implements Slack notification on workflow completion or failure
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: Notify Slack (always runs) | ||
| if: always() | ||
| env: | ||
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
| HOSTINGER_SITE_URL: ${{ secrets.HOSTINGER_SITE_URL }} | ||
| WP_PUSHER_REPO: ${{ secrets.WP_PUSHER_REPO }} | ||
| WP_PUSHER_DEPLOY_TYPE: ${{ secrets.WP_PUSHER_DEPLOY_TYPE }} | ||
| JOB_STATUS: ${{ job.status }} | ||
| REPO: ${{ github.repository }} | ||
| BRANCH: ${{ github.ref_name }} | ||
| RUN_ID: ${{ github.run_id }} | ||
| RUN_NUMBER: ${{ github.run_number }} | ||
| ACTOR: ${{ github.actor }} | ||
| EVENT_NAME: ${{ github.event_name }} | ||
| run: | | ||
| node scripts/slack-alert.js |
There was a problem hiding this comment.
The Slack notification step will run even if the slack-alert.js script doesn't exist or if SLACK_WEBHOOK_URL is not set, potentially masking failures. Add a conditional check to verify the webhook URL exists before attempting to run the notification script: if: always() && env.SLACK_WEBHOOK_URL != ''
| - name: Run tests | ||
| run: npm test | ||
|
|
There was a problem hiding this comment.
The npm test script is not defined in package.json. This will cause the workflow to fail. Add a "test" script to the "scripts" section of package.json, or remove this step if testing is not required.
| - name: Run tests | |
| run: npm test |
| - name: Build | ||
| run: npm run build | ||
|
|
There was a problem hiding this comment.
The npm run build script is not defined in package.json. This will cause the workflow to fail. Add a "build" script to the "scripts" section of package.json, or remove this step if building is not required.
| - name: Build | |
| run: npm run build |
| ACTOR: ${{ github.actor }} | ||
| EVENT_NAME: ${{ github.event_name }} | ||
| run: | | ||
| node scripts/slack-alert.js |
There was a problem hiding this comment.
The scripts/slack-alert.js file does not exist in the repository. This step will fail when executed. Create the slack-alert.js script in a scripts/ directory or update the path to point to an existing script.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This workflow runs on pushes and pull requests to the main branch, as well as on a daily schedule. It includes steps for checking out the code, setting up Node.js, installing dependencies, running linting and tests, building the project, and notifying Slack.