Browse Source

Setup GitHub Actions (#594)

Peter Justin 3 years ago
parent
commit
97426d20e7
3 changed files with 80 additions and 59 deletions
  1. 0 58
      .azure-pipelines.yml
  2. 80 0
      .github/workflows/tests.yml
  3. 0 1
      requirements.txt

+ 0 - 58
.azure-pipelines.yml

@@ -1,58 +0,0 @@
-trigger:
-  - 'master'
-
-jobs:
-  - job: FlaskBB
-    variables:
-      TOXENV: 'py,coverage-ci'
-
-    pool:
-      vmImage: ubuntu-latest
-
-    strategy:
-      matrix:
-        Python36:
-          python.version: '3.6'
-        Python37:
-          python.version: '3.7'
-        Python38:
-          python.version: '3.8'
-        Python39:
-          python.version: '3.9'
-      maxParallel: 4
-
-    steps:
-      - task: UsePythonVersion@0
-        inputs:
-          versionSpec: $(python.version)
-          architecture: x64
-        displayName: Use Python $(python.version)
-
-      - script: |
-          python -m pip install --upgrade pip
-          pip install pytest-azurepipelines
-          pip install -r requirements-dev.txt
-        displayName: Install dependencies
-
-      - script: flaskbb translations compile
-        displayName: Prepare FlaskBB
-
-      - script: tox -- --junitxml=test-results.xml
-        displayName: Run tox
-        env:
-          # Can't define in section 'variables' due it being a secret one
-          CODECOV_TOKEN: $(codecov.token)
-
-      - task: PublishTestResults@2
-        displayName: Publish test results
-        inputs:
-          testResultsFiles: test-results.xml
-          testRunTitle: $(Agent.JobName)
-        condition: succeededOrFailed()
-
-      - task: PublishCodeCoverageResults@1
-        displayName: Publish coverage results
-        inputs:
-          codeCoverageTool: Cobertura
-          summaryFileLocation: coverage.xml
-        condition: succeededOrFailed()

+ 80 - 0
.github/workflows/tests.yml

@@ -0,0 +1,80 @@
+# This workflow will install Python dependencies, run tests and lint with a single version of Python
+# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
+
+name: test
+
+on:
+  push:
+    branches: [ master ]
+    paths-ignore:
+      - 'docs/**'
+      - 'flaskbb/themes/**'
+      - '**.md'
+      - '**.rst'
+      - '**/CHANGES'
+      - '**/AUTHORS'
+      - '**/LICENSE'
+  pull_request:
+    branches: [ master ]
+    paths-ignore:
+      - 'docs/**'
+      - 'flaskbb/themes/**'
+      - '**.md'
+      - '**.rst'
+      - '**/CHANGES'
+      - '**/AUTHORS'
+      - '**/LICENSE'
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: [3.7, 3.8, 3.9]
+
+    steps:
+    - uses: actions/checkout@v2
+    
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+        
+    - name: Get pip cache dir
+      id: pip-cache
+      run: echo "::set-output name=dir::$(pip cache dir)"
+
+    - name: Cache pip
+      uses: actions/cache@v2
+      with:
+        path: ${{ steps.pip-cache.outputs.dir }}
+        key: pip|${{ runner.os }}|${{ matrix.python-version }}|${{ hashFiles('requirements*.txt') }}
+
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        pip install wheel
+        pip install -r requirements-dev.txt
+        pip install -e .
+
+    - name: Prepare FlaskBB
+      run: |
+        flaskbb translations compile
+
+    - name: Lint with flake8
+      run: |
+        # stop the build if there are Python syntax errors or undefined names
+        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
+        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
+        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
+        
+    - name: Test with pytest
+      run: |
+        pytest --cov=./ --cov-report=xml
+        
+    - name: Upload coverage to Codecov
+      uses: codecov/codecov-action@v1
+      with:
+        files: ./coverage.xml
+        flags: unittests
+        fail_ci_if_error: true

+ 0 - 1
requirements.txt

@@ -32,7 +32,6 @@ Flask-WTF==0.15.1
 flaskbb-plugin-conversations==1.0.7
 flaskbb-plugin-portal==1.1.3
 future==0.18.2
-greenlet==1.1.0
 idna==2.10
 itsdangerous==2.0.1
 Jinja2==3.0.1