Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions workflow for automated testing (#15) #29

Merged

Conversation

mattfsourcecode
Copy link
Owner

@mattfsourcecode mattfsourcecode commented Feb 15, 2025

Overview of the Workflow

This GitHub Actions workflow automates the testing of the fastify-swc-server CLI by installing the npm package and executing its bin script as if it were installed directly from the npm registry. This ensures the package performs as expected in a real-world usage scenario before pull requests are merged. The process includes validating the package's functionality, enabling compatibility with HTTPS for repository access, and addressing a required Node.js version upgrade.

The workflow performs the following steps:

  1. Checkout Code: The latest code is checked out from the repository using the actions/checkout action.
  2. Configure Git for HTTPS: The workflow configures Git to use HTTPS as the default method for cloning repositories.
  3. Validate Git Connection: A test is run to validate the Git connection using HTTPS, ensuring that the repository can be accessed without SSH keys.
  4. Set up pnpm: The pnpm package manager is set up with a specific version to handle dependency installation and management.
  5. Set up Node.js: The workflow installs Node.js (version lts/*), ensuring compatibility with the latest features and dependencies.
  6. Install Dependencies: Dependencies are installed using pnpm, while skipping the prepare script to prevent issues during installation.
  7. Pack and Install CLI: The workflow uses npm pack to package the CLI and installs it globally, verifying that the fastify-swc-server bin script works as expected.
  8. Test CLI Functionality: A test project is generated using the CLI, dependencies are installed, and the project is built and run in development mode. The server is then verified by making a request to the default URL.

These additional changes were required for the completion of the workflow:

  • Transitions the git clone command executed in the bin script to support HTTPS
  • Upgrades the minimum Node.js version requirement to v20

This setup supports a process where a version bump is the last change merged before the updated version is published to npm. This final step adds an additional layer of validation to ensure that the npm package, including any version updates, functions correctly. By testing the package’s functionality in the CI/CD pipeline, it confirms the integrity of the package and verifies that it works as intended before being made publicly available.

Closes #15

@mattfsourcecode mattfsourcecode force-pushed the add-github-actions-workflow-to-test-npm-package branch 21 times, most recently from 7357450 to 9f35c9f Compare February 15, 2025 05:53
@mattfsourcecode mattfsourcecode force-pushed the add-github-actions-workflow-to-test-npm-package branch from 9f35c9f to e2b3f06 Compare February 15, 2025 05:58
@mattfsourcecode mattfsourcecode changed the title WIP: Add GitHub Actions workflow for automated testing (#15) Add GitHub Actions workflow for automated testing (#15) Feb 15, 2025
@mattfsourcecode mattfsourcecode marked this pull request as ready for review February 15, 2025 06:14
@mattfsourcecode mattfsourcecode merged commit a907e3f into master Feb 15, 2025
1 check passed
@mattfsourcecode mattfsourcecode deleted the add-github-actions-workflow-to-test-npm-package branch February 15, 2025 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a GitHub Actions workflow for automated testing of the installed npm package
1 participant