Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .coveralls.yml

This file was deleted.

1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ ignore = E501, F403, C901, F601, W503
max-line-length = 79
max-complexity = 18
select = B,C,E,F,W,T4,B9
exclude = .git,docs/,env/,venv/,.venv,.venv39
36 changes: 36 additions & 0 deletions .github/CI_CD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# CI/CD and Release

This repository uses [GitHub Actions](https://github.com/Cloud-CV/evalai-cli/actions) for continuous integration and package publishing.

## Workflows

| Workflow | Purpose |
|----------|---------|
| `ci-cd.yml` | Lint, test, and publish packages |
| `upload-coverage.yml` | Upload test coverage to Codecov after CI succeeds |

## Required repository secrets

Configure these under **Settings → Secrets and variables → Actions**:

| Secret | Used for |
|--------|----------|
| `CODECOV_TOKEN` | Codecov upload |
| `TEST_PYPI_USERNAME` | TestPyPI publish on `staging` pushes |
| `TEST_PYPI_PASSWORD` | TestPyPI publish on `staging` pushes |
| `PYPI_API_TOKEN` | Production PyPI publish on tag pushes |

## GitHub environments

Create optional environments for publish job scoping and approvals:

- `staging` — TestPyPI publishes from the `staging` branch
- `production` — PyPI publishes from git tags

## Release process

1. Bump the version in `evalai/version.py`.
2. Push to `staging` to publish a test build to [TestPyPI](https://test.pypi.org/project/evalai/).
3. Create and push a git tag to publish to [PyPI](https://pypi.org/project/evalai/).

CI runs on pull requests and pushes to `master` and `staging` using Python 3.9.21 (aligned with the main EvalAI repository).
171 changes: 171 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
name: ci-cd

on:
push:
branches:
- master
- staging
tags:
- "*"
pull_request:
workflow_dispatch:
inputs:
publish_target:
description: "Optional manual publish target"
required: true
type: choice
options:
- none
- testpypi
default: none

concurrency:
group: ci-cd-${{ github.ref }}
cancel-in-progress: true

env:
PYTHON_RUNTIME_VERSION: "3.9.21"

jobs:
code_quality:
name: Code quality
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_RUNTIME_VERSION }}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
cache: pip

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8==7.1.2

- name: Run flake8
run: flake8 ./

test:
name: Tests
runs-on: ubuntu-latest
permissions:
contents: read
actions: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_RUNTIME_VERSION }}
cache: pip

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools==70.0.0
pip install -r requirements.txt
pip install \
coverage \
pytest==3.5.1 \
pytest-cov==2.5.1 \
pytest-env==0.6.2 \
responses==0.9.0

- name: Run tests with coverage
run: |
pytest \
--cov evalai \
--cov-config .coveragerc \
--cov-report=xml:coverage.xml

- name: Save pull request number for downstream coverage upload
run: |
mkdir -p pr-metadata
echo "${{ github.event.pull_request.number }}" > pr-metadata/pr_number.txt

- name: Upload test and coverage artifacts
uses: actions/upload-artifact@v4
with:
name: ci-test-reports
path: coverage.xml
if-no-files-found: error

- name: Upload pull request metadata artifact
uses: actions/upload-artifact@v4
with:
name: pr-metadata
path: pr-metadata/pr_number.txt
if-no-files-found: error

publish_to_testpypi:
name: Publish to TestPyPI
runs-on: ubuntu-latest
needs:
- code_quality
- test
if: >
(github.event_name == 'push' && github.ref == 'refs/heads/staging') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish_target == 'testpypi')
environment: staging
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_RUNTIME_VERSION }}
cache: pip

- name: Build and publish package to TestPyPI
env:
TWINE_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
run: |
python -m pip install --upgrade pip setuptools wheel twine
python setup.py sdist bdist_wheel
python -m twine upload \
--repository-url https://test.pypi.org/legacy/ \
dist/*

publish_to_pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs:
- code_quality
- test
if: startsWith(github.ref, 'refs/tags/')
environment: production
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_RUNTIME_VERSION }}
cache: pip

- name: Build and publish package to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python -m pip install --upgrade pip setuptools wheel twine
python setup.py sdist bdist_wheel
python -m twine upload dist/*
86 changes: 86 additions & 0 deletions .github/workflows/upload-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: upload-coverage

# Runs after ci-cd completes — in the BASE repo's security context so
# CODECOV_TOKEN is always available, including for fork PRs.
on:
workflow_run:
workflows: [ci-cd]
types: [completed]

permissions:
contents: read
actions: read
statuses: write

jobs:
upload_coverage:
name: Upload coverage to Codecov
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'

steps:
- name: Checkout repository (Codecov CLI reads codecov.yml from default branch)
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 1

- name: Download pull request metadata from triggering run
uses: actions/download-artifact@v4
with:
name: pr-metadata
path: pr-metadata
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Download test coverage artifact from triggering run
uses: actions/download-artifact@v4
with:
name: ci-test-reports
path: codecov-reports
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Resolve pull request number
id: pr
run: |
pr_number="$(tr -d '[:space:]' < pr-metadata/pr_number.txt || true)"
echo "number=${pr_number}" >> "$GITHUB_OUTPUT"

- name: Verify coverage file exists
run: test -f codecov-reports/coverage.xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: codecov-reports/coverage.xml
flags: cli
disable_search: true
fail_ci_if_error: true
verbose: true
override_commit: ${{ github.event.workflow_run.head_sha }}
override_branch: ${{ github.event.workflow_run.head_branch }}
override_pr: ${{ steps.pr.outputs.number }}

- name: Report coverage upload status to triggering commit
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ github.event.workflow_run.head_sha }}
CONCLUSION: ${{ job.status }}
run: |
if [ "${CONCLUSION}" = "success" ]; then
state="success"
description="Coverage uploaded to Codecov successfully."
else
state="failure"
description="Coverage upload to Codecov failed."
fi
gh api \
--method POST \
"/repos/${{ github.repository }}/statuses/${SHA}" \
--field state="${state}" \
--field description="${description}" \
--field context="upload-coverage / Codecov" \
--field target_url="https://app.codecov.io/gh/${{ github.repository }}"
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: stable
hooks:
- id: black
language_version: python3.7
language_version: python3.9
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.2.3
hooks:
Expand Down
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ EvalAI-CLI is designed to extend the functionality of the EvalAI web application
------------------------------------------------------------------------------------------

[![Join the chat at https://gitter.im/Cloud-CV/EvalAI](https://badges.gitter.im/Cloud-CV/EvalAI.svg)](https://gitter.im/Cloud-CV/EvalAI?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/Cloud-CV/evalai-cli.svg?branch=master)](https://travis-ci.org/Cloud-CV/evalai-cli)
[![Coverage Status](https://coveralls.io/repos/github/Cloud-CV/evalai-cli/badge.svg?branch=master)](https://coveralls.io/github/Cloud-CV/evalai-cli?branch=master)
[![CI/CD](https://github.com/Cloud-CV/evalai-cli/actions/workflows/ci-cd.yml/badge.svg?branch=master)](https://github.com/Cloud-CV/evalai-cli/actions/workflows/ci-cd.yml)
[![CodeRabbit Reviews](https://img.shields.io/coderabbit/prs/github/Cloud-CV/evalai-cli?style=flat-square)](https://coderabbit.ai)
[![codecov](https://codecov.io/gh/Cloud-CV/evalai-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/Cloud-CV/evalai-cli)
[![Documentation Status](https://readthedocs.org/projects/markdown-guide/badge/?version=latest)](https://cli.eval.ai/)

## Installation
Expand Down
40 changes: 40 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
codecov:
branch: master
strict_yaml_branch: master

coverage:
precision: 2
round: down
range: "70...100"
ignore:
- "*/python?.?/*"
- "*/tests/*"
- "setup.py"
status:
project:
default:
target: 70%
threshold: 1%
flags:
- cli
if_ci_failed: error
informational: false
patch:
default:
target: 80%
threshold: 0%
if_ci_failed: error
only_pulls: true

flags:
cli:
paths:
- evalai/

comment:
layout: "header, diff, flags, files, footer"
behavior: default
require_head: yes

github_checks:
annotations: true
Loading
Loading