diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64a37745..80480cf2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,24 +1,24 @@ # If you change the name, change the link on the README.md for the badge too name: Tests +permissions: + contents: read + actions: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + on: push: - paths: - - sc2/** - - examples/** - - test/** - - docs_generate/** - - .pre-commit-config.yaml - - generate_dicts_from_data_json.py - - generate_id_constants_from_stableid.py - - uv.lock - - pyproject.toml - - README.md - - .github/workflows/ci.yml + branches: + - master + - develop pull_request: branches: - master - develop + workflow_dispatch: {} env: # Docker image version, see https://hub.docker.com/r/burnysc2/python-sc2-docker/tags @@ -35,19 +35,21 @@ jobs: timeout-minutes: 10 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Set up Python ${{ env.LATEST_PYTHON_VERSION }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v7 with: python-version: ${{ env.LATEST_PYTHON_VERSION }} - name: Install uv - run: pip install uv + uses: astral-sh/setup-uv@v10.3.0 + with: + enable-cache: true - name: Install dependencies run: | - uv sync --frozen --no-cache --no-install-project + uv sync --frozen --no-install-project uv run pre-commit install - name: Run pre-commit hooks @@ -59,19 +61,21 @@ jobs: timeout-minutes: 10 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Set up Python ${{ env.LATEST_PYTHON_VERSION }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v7 with: python-version: ${{ env.LATEST_PYTHON_VERSION }} - name: Install uv - run: pip install uv + uses: astral-sh/setup-uv@v10.3.0 + with: + enable-cache: true - name: Install dependencies run: | - uv sync --frozen --no-cache --no-install-project + uv sync --frozen --no-install-project uv run pre-commit install - name: Run generate dicts @@ -84,7 +88,7 @@ jobs: rm -rf sc2/dicts/__pycache__ sc2/dicts_old/__pycache__ - name: Upload generated dicts folder as artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: Generated_dicts path: sc2/dicts @@ -112,19 +116,21 @@ jobs: python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Set up Python ${{ matrix.python-version }} id: setup-python - uses: actions/setup-python@v4 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} - name: Install uv - run: pip install uv + uses: astral-sh/setup-uv@v10.3.0 + with: + enable-cache: true - name: Install dependencies - run: uv sync --frozen --no-cache --no-install-project + run: uv sync --frozen --no-install-project - name: Run pytest run: uv run python -m pytest test @@ -169,7 +175,7 @@ jobs: steps: # Copy data from repository - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Print directories and files run: sudo apt-get install tree && tree @@ -220,7 +226,7 @@ jobs: steps: # Copy data from repository - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Print directories and files run: sudo apt-get install tree && tree @@ -249,7 +255,7 @@ jobs: # # steps: # # Copy data from repository - # - uses: actions/checkout@v3 + # - uses: actions/checkout@v7 # # - name: Print directories and files # run: | @@ -281,7 +287,7 @@ jobs: IMAGE_NAME: burnysc2/python-sc2-docker:local steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Load and build docker image # Build docker image from Dockerfile using specific python and sc2 version @@ -333,7 +339,7 @@ jobs: echo "Upload htmlcov folder because it was mounted in container, so it will be available in host machine" - name: Upload htmlcov/ folder as artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: Coverage_report path: htmlcov @@ -345,18 +351,20 @@ jobs: timeout-minutes: 10 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Set up Python ${{ env.LATEST_PYTHON_VERSION }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v7 with: python-version: ${{ env.LATEST_PYTHON_VERSION }} - name: Install uv - run: pip install uv + uses: astral-sh/setup-uv@v10.3.0 + with: + enable-cache: true - name: Install dependencies - run: uv sync --frozen --no-cache --no-install-project + run: uv sync --frozen --no-install-project - name: Run uv radon run: uv run radon cc sc2/ -a -nb @@ -368,18 +376,20 @@ jobs: timeout-minutes: 5 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Set up Python ${{ env.LATEST_PYTHON_VERSION }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v7 with: python-version: ${{ env.LATEST_PYTHON_VERSION }} - name: Install uv - run: pip install uv + uses: astral-sh/setup-uv@v10.3.0 + with: + enable-cache: true - name: Install dependencies - run: uv sync --frozen --no-cache --no-install-project + run: uv sync --frozen --no-install-project - name: Build docs from scratch run: | @@ -393,7 +403,7 @@ jobs: - name: Publish to Github Pages if: github.ref == 'refs/heads/develop' && github.event_name == 'push' - uses: JamesIves/github-pages-deploy-action@releases/v4 + uses: JamesIves/github-pages-deploy-action@v4 with: ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} BASE_BRANCH: develop # The branch the action should deploy from. @@ -407,15 +417,17 @@ jobs: timeout-minutes: 10 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Set up Python ${{ env.LATEST_PYTHON_VERSION }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v7 with: python-version: ${{ env.LATEST_PYTHON_VERSION }} - name: Install uv - run: pip install uv + uses: astral-sh/setup-uv@v10.3.0 + with: + enable-cache: true - name: Remove test folder to not include it in package run: rm -rf test diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index e3f04b23..c7796fce 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -1,17 +1,23 @@ name: Build and push Docker image -# Only run if Dockerfile or docker-ci.yml changed +permissions: + contents: read + actions: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + on: push: - paths: - - dockerfiles/** - - uv.lock - - pyproject.toml - - .github/workflows/docker-ci.yml + branches: + - master + - develop pull_request: branches: - master - develop + workflow_dispatch: {} env: VERSION_NUMBER: "1.0.7" @@ -30,10 +36,10 @@ jobs: os: [ubuntu-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Cache sc2 maps - uses: actions/cache@v4 + uses: actions/cache@v6 id: cache-sc2-maps with: path: | @@ -57,10 +63,10 @@ jobs: os: [ubuntu-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Cache sc2 maps - uses: actions/cache@v4 + uses: actions/cache@v6 id: cache-sc2-maps with: path: | @@ -91,10 +97,10 @@ jobs: os: [ubuntu-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Cache sc2 maps - uses: actions/cache@v4 + uses: actions/cache@v6 id: cache-sc2-maps with: path: | @@ -131,10 +137,10 @@ jobs: BUILD_ARGS: --build-arg PYTHON_VERSION=${{ matrix.python-version }} --build-arg SC2_VERSION=${{ matrix.sc2-version }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Cache sc2 maps - uses: actions/cache@v4 + uses: actions/cache@v6 id: cache-sc2-maps with: path: | @@ -173,7 +179,7 @@ jobs: - name: Login to DockerHub if: github.ref == 'refs/heads/develop' && github.event_name == 'push' - uses: docker/login-action@v2 + uses: docker/login-action@v4 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }}