diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 12af011..18e5d4c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,6 +2,9 @@ ARG UBUNTU_VERSION=20.04 FROM ubuntu:${UBUNTU_VERSION} AS base +LABEL org.opencontainers.image.source=https://github.com/cfe-lab/gotoh +LABEL org.opencontainers.image.description="Gotoh dev container for development and testing" + ARG DEBIAN_FRONTEND=noninteractive ENV TZ=America/Vancouver \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 49fa4fd..7e62f97 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,11 +5,11 @@ "build": { "dockerfile": "Dockerfile" - } + }, + + "updateContentCommand": "cd /workspaces/gotoh/ruby && bundle install", "features": { - "ghcr.io/devcontainers/features/ruby:1": { - "version": "2.2" - } + "ghcr.io/devcontainers/features/git:1": {} } } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a61f2c9..4064492 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,33 +3,29 @@ name: Automated Tests on: ["push"] jobs: - build: - runs-on: [self-hosted] + test: + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout code from repo + uses: actions/checkout@v3 + + - name: Log into GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build devcontainer and run tests + uses: devcontainers/ci@v0.3 with: - submodules: 'true' - - name: Setup pipenv - run: | - pip install --upgrade pip - python -m venv venv - ./venv/bin/pip install --upgrade pip - ./venv/bin/pip install pipenv - - name: Install dependencies - run: | - PIPENV_VENV_IN_PROJECT=1 ./venv/bin/pipenv sync -d - # - name: Dummy settings file - # run: cp phylowatch/settings_default.py phylowatch/settings.py - - name: Static checks - run: | - ./.venv/bin/flake8 phylowatch --show-source --statistics - ./.venv/bin/flake8 tests --show-source --statistics - continue-on-error: true - - name: Unit tests - run: ./.venv/bin/pytest --cov-config=.coveragerc --cov --cov-report=xml:coverage.xml --mpl tests + imageName: ghcr.io/cfe-lab/gotoh_devcontainer + cacheFrom: ghcr.io/cfe-lab/gotoh_devcontainer + runCmd: cd ${{ github.workspace }}/ruby && rake test + - name: Upload coverage reports to Codecov with GitHub Action - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} root_dir: ${{ github.workspace }} - files: ${{ github.workspace }}/coverage.xml + files: ${{ github.workspace }}/ruby/coverage/coverage.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100755 index 6cbb6b7..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,124 +0,0 @@ -variables: - UBUNTU_VERSION: - value: "20.04" - description: Version of ubuntu to test against - RUBY_VERSION: - value: "2.2.2" - description: Version of ruby to test against - PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}" - -stages: - - test - - release - -# ----------------------------------------------------- -# Test Stage - -unit-tests: - image: - name: git-int.cfenet.ubc.ca:5005/cfe/cfe_ubuntu/ruby:${UBUNTU_VERSION} - pull_policy: if-not-present - stage: test - script: - - cd $CI_PROJECT_DIR - - source /etc/profile.d/rvm.sh - - bundle install - - rake - - cp test/html_reports/index.html ./$(date +%Y%m%d)_${CI_PROJECT_NAME}_test_report.html - artifacts: - when: always - reports: - junit: $CI_PROJECT_DIR/test/reports/*.xml - coverage_report: - coverage_format: cobertura - path: $CI_PROJECT_DIR/coverage/coverage.xml - expire_in: 1 month - paths: - - coverage - - "*_${CI_PROJECT_NAME}_test_report.html" - coverage: /\((\d+\.\d+)\%\) covered\.$/ - rules: - - if: $CI_DEFAULT_BRANCH == $CI_COMMIT_BRANCH - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - -# ----------------------------------------------------- -# Release Stage - -.release-rules: - stage: release - rules: - - if: $CI_COMMIT_TAG - variables: - GEMFILE_FILENAME: ${CI_PROJECT_NAME}-${CI_COMMIT_TAG}.gem - -build-gem: - image: - name: git-int.cfenet.ubc.ca:5005/cfe/cfe_ubuntu/ruby:${UBUNTU_VERSION} - pull_policy: if-not-present - extends: .release-rules - variables: - HIVDB_ALGORITHM_VERSION: $CI_COMMIT_TAG # the gemspec will look for this in the environment - script: - - cd $CI_PROJECT_DIR - - source /etc/profile.d/rvm.sh - - bundle install - - gem build ${CI_PROJECT_NAME}.gemspec --output build/${GEMFILE_FILENAME} - artifacts: - paths: - - build/${GEMFILE_FILENAME} - -upload-gem: - image: - name: alpine:latest - pull_policy: if-not-present - needs: - - build-gem - extends: .release-rules - variables: - GIT_STRATEGY: none - script: - - apk --no-cache add curl - - 'curl - --fail - --header "JOB-TOKEN: $CI_JOB_TOKEN" - --upload-file build/${GEMFILE_FILENAME} - ${PACKAGE_REGISTRY_URL}/${GEMFILE_FILENAME}' - -push-to-rubygems-int: - image: - name: git-int.cfenet.ubc.ca:5005/cfe/cfe_ubuntu/ruby:${UBUNTU_VERSION} - pull_policy: if-not-present - extends: .release-rules - variables: - GIT_STRATEGY: none - # this keyword specifies we will get the artifacts from the stage - needs: - - build-gem - - upload-gem - before_script: - - cd $CI_PROJECT_DIR - script: - - source /etc/profile.d/rvm.sh - # We don't specify a key here because we insert the $GEM_HOST_API_KEY via gitlab secrets - - gem push --host https://rubygems-int.bccfe.ca/private build/${GEMFILE_FILENAME} - environment: - name: release/${CI_COMMIT_TAG} - on_stop: yank-gem-from-rubygems-int - -yank-gem-from-rubygems-int: - image: - name: git-int.cfenet.ubc.ca:5005/cfe/cfe_ubuntu/ruby:${UBUNTU_VERSION} - pull_policy: if-not-present - extends: .release-rules - variables: - GIT_STRATEGY: none - before_script: - - cd $CI_PROJECT_DIR - script: - - source /etc/profile.d/rvm.sh - # We don't specify a key here because we insert the $GEM_HOST_API_KEY via gitlab secrets - - gem yank ${CI_PROJECT_NAME} --version ${CI_COMMIT_TAG} - environment: - name: release/${CI_COMMIT_TAG} - action: stop - when: manual