From 02d0bc18cfca4cb7bf51af9bc1788338add9cc40 Mon Sep 17 00:00:00 2001 From: Mathieu Scheltienne Date: Thu, 30 May 2024 15:23:48 +0200 Subject: [PATCH] Improve github CIs (#182) * run publish on 3.11 and check befor eupload * run stubs on 3.11 * make dataset caching DRY --- .../actions/get-testing-dataset/action.yaml | 22 +++++++++++++ .github/workflows/publish.yaml | 6 ++-- .github/workflows/pytest.yaml | 32 +++---------------- .github/workflows/stubs.yaml | 5 ++- 4 files changed, 31 insertions(+), 34 deletions(-) create mode 100644 .github/actions/get-testing-dataset/action.yaml diff --git a/.github/actions/get-testing-dataset/action.yaml b/.github/actions/get-testing-dataset/action.yaml new file mode 100644 index 00000000..7ea22def --- /dev/null +++ b/.github/actions/get-testing-dataset/action.yaml @@ -0,0 +1,22 @@ +name: "Get MNE testing dataset" +description: "A composite action to get MNE testing dataset from cache or remote." + +runs: + using: "composite" + steps: + - name: Get testing dataset version + shell: bash + run: curl https://raw.githubusercontent.com/mne-tools/mne-testing-data/master/version.txt -o mne_testing_data_version.txt + - name: Cache testing dataset + id: cache + uses: actions/cache@v4 + with: + key: mne-testing-${{ runner.os }}-${{ hashFiles('mne_testing_data_version.txt') }} + path: ~/mne_data + - name: Download testing dataset + if: steps.cache.outputs.cache-hit != 'true' + shell: bash + run: python -c "import mne; mne.datasets.testing.data_path(verbose=True)" + - name: Remove dataset version file + shell: bash + run: rm mne_testing_data_version.txt diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 6fcb3b14..00c6815c 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -12,11 +12,10 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup Python 3.9 + - name: Setup Python 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - architecture: 'x64' + python-version: 3.11 - name: Install dependencies run: | python -m pip install --progress-bar off --upgrade pip setuptools @@ -31,4 +30,5 @@ jobs: TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} run: | python -m build + twine check dist/* twine upload dist/* diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index d5c9aa47..1bc3f85a 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -38,20 +38,8 @@ jobs: run: pycrostates-sys_info --developer - name: Display MNE info run: mne sys_info -pd - - name: Get testing dataset version - run: | - curl https://raw.githubusercontent.com/mne-tools/mne-testing-data/master/version.txt -o mne_testing_data_version.txt - - name: Cache testing dataset - id: cache - uses: actions/cache@v4 - with: - key: mne-testing-${{ runner.os }}-${{ hashFiles('mne_testing_data_version.txt') }} - path: ~/mne_data - - name: Download testing dataset - if: steps.cache.outputs.cache-hit != 'true' - run: python -c "import mne; mne.datasets.testing.data_path(verbose=True)" - - name: Remove dataset version file - run: rm mne_testing_data_version.txt + - name: Get testing dataset + uses: ./.github/actions/get-testing-dataset - name: Run pytest run: pytest pycrostates --cov=pycrostates --cov-report=xml --cov-config=pyproject.toml - name: Upload to codecov @@ -93,20 +81,8 @@ jobs: run: pycrostates-sys_info --developer - name: Display MNE info run: mne sys_info -pd - - name: Get testing dataset version - run: | - curl https://raw.githubusercontent.com/mne-tools/mne-testing-data/master/version.txt -o mne_testing_data_version.txt - - name: Cache testing dataset - id: cache - uses: actions/cache@v4 - with: - key: mne-testing-${{ runner.os }}-${{ hashFiles('mne_testing_data_version.txt') }} - path: ~/mne_data - - name: Download testing dataset - if: steps.cache.outputs.cache-hit != 'true' - run: python -c "import mne; mne.datasets.testing.data_path(verbose=True)" - - name: Remove dataset version file - run: rm mne_testing_data_version.txt + - name: Get testing dataset + uses: ./.github/actions/get-testing-dataset - name: Run pytest run: pytest pycrostates --cov=pycrostates --cov-report=xml --cov-config=pyproject.toml - name: Upload to codecov diff --git a/.github/workflows/stubs.yaml b/.github/workflows/stubs.yaml index 890461d2..66a6d10c 100644 --- a/.github/workflows/stubs.yaml +++ b/.github/workflows/stubs.yaml @@ -18,11 +18,10 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup Python 3.9 + - name: Setup Python 3.11 uses: actions/setup-python@v5 with: - python-version: 3.9 - architecture: 'x64' + python-version: 3.11 - name: Install package run: | python -m pip install --progress-bar off --upgrade pip setuptools