Continuous Integration

Continuous integration testing is done to ‘ensure’ that API Endpoints, database checks and ‘any’ defined execution runs continuously and unattended.

Below is an example of the .YAML architecture in GitHub Actions for that.

name: Antonio Rodriguez - API Tests

on:
  schedule:
    - cron: '0 7-15/2 * * 1-4'
    - cron: '0 7-12/2 * * 5'

jobs:
  test_monday_thursday:
    if: github.event.schedule == '0 7-15/2 * * 1-4'
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.10"]
    defaults:
      run:
        working-directory: Jenkins-CI/backend-tests
    env:
      API_KEY: ${{ secrets.API_KEY }}

    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
      with:
        node-version: 20
    
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}
        cache: 'pip'
        
    - name: Install Python dependencies
      uses: py-actions/py-dependency-install@v4
      with:
        update-pip: "true"
        update-setuptools: "true"
        update-wheel: "true"
        path: "Jenkins-CI/backend-tests/requirements.txt"
        
    - name: Config ServiceAccountKey.json    # firebase private key passed as a github secret in json format
      uses: jsdaniell/create-json@v1.2.3
      with:
        name: "serviceAccountKey.json"
        json: ${{ secrets.ACCOUNT_KEY }}
        dir: 'Jenkins-CI/backend-tests'

        
    - name: Run Test Example1
      run: python test_Example1.py
      
    - name: Run Test Example2
      run: python test_Example2.py

      
    - name: Upload report .HTML
      uses: actions/upload-artifact@v4
      with:
        name: api_test_report.html
        path: Jenkins-CI/backend-tests/*.html
    
   # Protected branch hook declined
    # - name: Push .HTML to Repo
      # uses: actions-x/commit@v6
       # with:
         # email: antonio@rodriguezfarias.com
         # name: Antonio Rodriguez Farias
         # message: download .HTML to see report
         # branch: main
         # files: .
         # repository: https://github.com/AntoniHub/C0D3X.git
         # token: ${{ secrets.PAT }}
         # force: true
         # directory: Jenkins-CI/backend-tests