libratom/libratom

View on GitHub
.github/workflows/test_suite.yml

Summary

Maintainability
Test Coverage
name: Build, Test, Release

on:
  - push

jobs:
  test:
    name: Run the test suite
    runs-on: ${{ matrix.os }}
    env:
      TEST_DATA_DIR: /tmp/libratom/test_data
      EDRM_DIR: /tmp/libratom/test_data/RevisedEDRMv1_Complete
      CACHED_HTTPD_USERS_MAIL_DIR: /tmp/libratom/test_data/httpd-users
    strategy:
      matrix:
#        os: [ubuntu-latest, macos-latest, windows-latest]
        os: [ubuntu-latest, macos-latest]
        python-version: ["3.8", "3.9", "3.10"]
    steps:
    - uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
    - uses: actions/checkout@v3
    - name: Download Enron data from github storage
      uses: dawidd6/action-download-artifact@v2
      with:
        workflow: cache_pst_data.yml
        path: ${{ env.EDRM_DIR }}
    - name: Download mbox data from github storage
      uses: dawidd6/action-download-artifact@v2
      with:
        workflow: cache_mbox_data.yml
        path: ${{ env.TEST_DATA_DIR }}  # One level up from CACHED_HTTPD_USERS_MAIL_DIR
    - name: Confirm test data is present
      run: |
        find ${{ env.EDRM_DIR }} -type f
        find ${{ env.CACHED_HTTPD_USERS_MAIL_DIR }} -type f
    - name: Install tox
      run: |
        python -m pip install --upgrade pip
        pip install tox tox-gh-actions
    - name: Let tox run the test suite
      env:
        # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: tox
    - name: Upload coverage results
      uses: codecov/codecov-action@v3
      with:
        files: ./coverage.xml
        fail_ci_if_error: true
        verbose: true
  publish:
    name: Release (PYPI)
    needs: test
    runs-on: ubuntu-20.04
    # First condition is to not run on forks
    # Second condition is to run only on push to main or tags
    if: |
      github.repository_owner == 'libratom' &&
      (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: '0'  # PBR needs commit and tag history to set version
      - uses: actions/setup-python@v4
        with:
          python-version: 3.9
      - name: Install build dependencies
        run: |
          python -m pip install --upgrade pip
          pip install wheel pbr
      - name: Build
        run: python setup.py sdist bdist_wheel
#      - name: Test Publish
#        uses: pypa/gh-action-pypi-publish@release/v1
#        with:
#          user: __token__
#          password: ${{ secrets.TEST_PYPI_API_TOKEN }}
#          repository_url: https://test.pypi.org/legacy/
#          skip_existing: true
      - name: Publish
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}
          skip_existing: true