diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..a9c67305 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,73 @@ +name: Tests + +on: + push: + pull_request: + schedule: + - cron: '0 0 * * *' # every day at midnight + +jobs: + build: + if: ${{ github.repository == 'slaclab/Badger' }} + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + strategy: + max-parallel: 1 + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.9", "3.11"] + env: + DISPLAY: ':99.0' + QT_MAC_WANTS_LAYER: 1 # PyQT gui tests involving qtbot interaction on macOS will fail without this + steps: + - name: Setup Mambaforge + uses: conda-incubator/setup-miniconda@v2 + with: + miniforge-variant: Mambaforge + miniforge-version: latest + activate-environment: badger-dev + use-mamba: true + python-version: ${{ matrix.python-version }} + + - uses: actions/checkout@v3 + + - name: Get Date + id: get-date + run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT + shell: bash + + - name: Cache Conda env + uses: actions/cache@v3 + with: + path: ${{ env.CONDA }}/envs + key: + conda-${{ runner.os }}--${{ runner.arch }}--${{ github.workflow }}--${{ + steps.get-date.outputs.today }}--${{ + hashFiles('environment.yml') }}--${{ env.CACHE_NUMBER }}--${{ matrix.python-version }} + env: + CACHE_NUMBER: 0 + id: cache + + - name: Setup Mambaforge for real if not cached + uses: conda-incubator/setup-miniconda@v2 + with: + miniforge-variant: Mambaforge + miniforge-version: latest + activate-environment: badger-dev + use-mamba: true + python-version: ${{ matrix.python-version }} + environment-file: environment.yml + if: steps.cache.outputs.cache-hit != 'true' + + - name: Install Badger + shell: bash -l {0} + run: | + pip uninstall -y badger-opt || true + pip install --no-dependencies . + + - name: Run Tests + shell: bash -l {0} + run: | + python scripts/run_tests.py \ No newline at end of file