Skip to content

[FEATURE] Use QuickType to generate schemas/DTO files via GitHub Actions #268

Open
@guibranco

Description

@guibranco

Description

Implement a GitHub Actions workflow to automatically generate schemas and Data Transfer Object (DTO) files using QuickType. This will help keep our data models up-to-date and synchronized with our data sources, streamlining the development process.

Why We Need This

  1. Automation: Automatically generating schemas and DTO files ensures they are always up-to-date with the latest changes, reducing manual effort and the risk of inconsistencies.
  2. Consistency: Using a consistent tool like QuickType across the team helps maintain uniform data models and reduces errors.
  3. Efficiency: Integrating schema generation into our CI/CD pipeline will speed up development and ensure that data models are always accurate.

Tech Notes

  1. QuickType Integration:

    • QuickType can generate schemas and DTO files from JSON, TypeScript, or other data formats.
    • We need to set up QuickType to run as part of our GitHub Actions workflow.
  2. GitHub Actions Workflow Setup:

    • Create a new workflow file in .github/workflows directory, e.g., generate-schemas.yml.
    • Define a job in the workflow to install QuickType and run it to generate the required files.
  3. Workflow File Example:

    name: Generate Schemas/DTO Files
    
    on:
      push:
        branches:
          - main
      pull_request:
        branches:
          - main
    
    jobs:
      generate:
        runs-on: ubuntu-latest
    
        steps:
          - name: Checkout code
            uses: actions/checkout@v3
    
          - name: Set up Node.js
            uses: actions/setup-node@v3
            with:
              node-version: "14"
    
          - name: Install QuickType
            run: npm install -g quicktype
    
          - name: Generate Schemas/DTO Files
            run: quicktype -s json -o src/schemas.ts data/example.json
    
          - name: Commit generated files
            run: |
              git config --global user.name 'GitHub Actions'
              git config --global user.email 'actions@github.com'
              git add src/schemas.ts
              git commit -m 'Update generated schemas/DTO files'
              git push
  4. QuickType Command Details:

    • Customize the quicktype command based on your data source and output requirements.
    • Refer to QuickType CLI documentation for additional options and configurations.
  5. File Management:

    • Ensure that the generated files are correctly placed in the repository and managed according to your project’s file structure.
    • Set up .gitignore if there are any temporary files or outputs that should not be committed.

Additional Notes

  • Ensure that the workflow is tested in a staging environment before deploying it to production.
  • Consider adding tests to verify the accuracy of generated schemas/DTO files.
  • Document the process and any configurations in the repository’s README or contributing guidelines.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    :octocat: github-actionsGitHub Actions for automation and CI/CDCIContinuous Integration / PipelineCode QualityCode QualitydependenciesPull requests that update a dependency fileenhancementA enhancement to the projectexamplesExamplesgitautoGitAuto label to trigger the app in a issue.good first issueA issue for someone self assign and help me =DhacktoberfestParticipation in the Hacktoberfest eventhelp wantedFeel free to take this issue for you and help me!schemaRequest of new schema/model📝 documentationTasks related to writing or updating documentation🛠 WIPWork in progress

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions