Skip to content

CI

CI #1443

Workflow file for this run

# Continuous Integration
# This workflow downloads Slack over different environments
# and perform test runs of the install script
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: "0 0 * * *"
env:
CI_VERSION: ci-v2.1
jobs:
# Job to download slack for eacg platform and cache the installer
download_slack:
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ubuntu, windows, macOS]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install Dependencies
run: |
pip install autoscraper==1.1.10
shell: bash
- name: Find Latest Slack URL and Versions
run: |
export SLACK_VERSION=`python .github/workflows/download_slack.py --get-version ${{ matrix.os }}`
echo "${SLACK_VERSION}" > ${{ matrix.os }}-version.txt
echo "SLACK_VERSION=${SLACK_VERSION}" >> $GITHUB_ENV
shell: bash
# Save the versions as caches
- name: Save Slack Version
uses: actions/cache@v2
with:
path: ${{ matrix.os }}-version.txt
key: ${{ env.CI_VERSION }}-${{ matrix.os }}-slack-version=${{ env.SLACK_VERSION }}
# Cache downloaded Slack
- name: Cache Slack
id: cache-download
uses: actions/cache@v2
with:
path: slack-download-${{ matrix.os }}
key: ${{ env.CI_VERSION }}-${{ matrix.os }}-slack-${{ env.SLACK_VERSION }}
# Actual download if cache misses
- name: Get Slack Download URL and Prepare Download
if: steps.cache-download.outputs.cache-hit != 'true'
run: |
export SLACK_DOWNLOAD_URL=$(python .github/workflows/download_slack.py --get-download-url ${{ matrix.os }})
echo "SLACK_DOWNLOAD_URL=${SLACK_DOWNLOAD_URL}" >> $GITHUB_ENV
mkdir -p slack-download-${{ matrix.os }}
shell: bash
- name: Download Slack Ubuntu
if: steps.cache-download.outputs.cache-hit != 'true' && matrix.os == 'ubuntu'
run: |
wget "${{ env.SLACK_DOWNLOAD_URL }}" -O slack-download-ubuntu/slack.rpm
- name: Download Slack MacOS
if: steps.cache-download.outputs.cache-hit != 'true' && matrix.os == 'macOS'
run: |
wget "${{ env.SLACK_DOWNLOAD_URL }}" -O slack-download-macOS/slack.dmg
- name: Download Slack Windows
if: steps.cache-download.outputs.cache-hit != 'true' && matrix.os == 'windows'
run: |
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile("${{ env.SLACK_DOWNLOAD_URL }}", "slack-download-windows\slack.exe")
build:
needs: download_slack
continue-on-error: true
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ubuntu]
python-version: [3.7, 3.8, 3.9, pypy-3.7]
include:
- os: macOS
python-version: 3.6
- os: windows
python-version: 3.6
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
shell: bash
- name: Get Slack Version (step 1)
uses: actions/cache@v2
with:
path: ${{ matrix.os }}-version.txt
key: ${{ env.CI_VERSION }}-${{ matrix.os }}-${{ github.run_number }}
restore-keys: ${{ env.CI_VERSION }}-${{ matrix.os }}-slack-version=
- name: Get Slack Version (step 2)
run: |
version=`cat ${{ matrix.os }}-version.txt`
echo "SLACK_VERSION=${version}" >> $GITHUB_ENV
shell: bash
- name: Get Slack Downloaded from cache
uses: actions/cache@v2
with:
path: slack-download-${{ matrix.os }}
key: ${{ env.CI_VERSION }}-${{ matrix.os }}-slack-${{ env.SLACK_VERSION }}
- name: Install Slack (Ubuntu)
run: |
sudo apt-get install alien
sudo alien -i -k slack-download-ubuntu/slack.rpm
if: matrix.os == 'ubuntu'
- name: Install Slack (MacOS)
run: |
hdiutil attach slack-download-macOS/slack.dmg
sudo cp -rf /Volumes/Slack/Slack.app /Applications
if: matrix.os == 'macOS'
- name: Install Slack (Windows)
run: |
.\slack-download-windows\slack.exe
while (!(Test-Path "$env:LOCALAPPDATA\slack\app-${{ env.SLACK_VERSION }}\resources\app.asar")) { Start-Sleep 10 }
Stop-Process -Name slack -passthru| Wait-Process
if: matrix.os == 'windows'
- 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 run the script (Ubuntu and MacOS)
run: |
sudo python math-with-slack.py
if: matrix.os == 'ubuntu' || matrix.os == 'macOS'
- name: Test run the script (Windows)
run: |
python math-with-slack.py -a "${LOCALAPPDATA}\slack\app-${{ env.SLACK_VERSION }}\resources\app.asar"
shell: bash
if: matrix.os == 'windows'
- name: Prepare Badge Creation
run: |
if [ "${{ matrix.os }}" = "macOS" ]; then
BADGE_LOGO="apple"
else
BADGE_LOGO=${{ matrix.os }}
fi
echo "BADGE_LOGO=${BADGE_LOGO}" >> $GITHUB_ENV
shell: bash
if: ${{ always() && github.event_name != 'pull_request' }}
- name: Create Success Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.BADGE_GIST_ID }}
filename: ${{ matrix.os }}-${{ matrix.python-version }}.json
label: ${{ matrix.os }} | Python ${{ matrix.python-version }} | Slack ${{ env.SLACK_VERSION }}
namedLogo: ${{ env.BADGE_LOGO }}
message: passing
color: green
if: ${{ success() && github.event_name != 'pull_request' }}
- name: Create Unknown Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.BADGE_GIST_ID }}
filename: ${{ matrix.os }}-${{ matrix.python-version }}.json
label: ${{ matrix.os }} | Python ${{ matrix.python-version }} | Slack ${{ env.SLACK_VERSION }}
message: unknown
namedLogo: ${{ env.BADGE_LOGO }}
color: lightgrey
if: ${{ cancelled() && github.event_name != 'pull_request' }}
- name: Create Failure Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.BADGE_GIST_ID }}
filename: ${{ matrix.os }}-${{ matrix.python-version }}.json
label: ${{ matrix.os }} | Python ${{ matrix.python-version }} | Slack ${{ env.SLACK_VERSION }}
message: failed
namedLogo: ${{ env.BADGE_LOGO }}
isError: true
if: ${{ failure() && github.event_name != 'pull_request' }}
- name: Set exit code (Step 1)
run: touch failed.txt
shell: bash
if: ${{ failure() }}
- name: Set exit code (Step 2)
uses: pat-s/[email protected]
with:
path: failed.txt
key: ${{ env.CI_VERSION }}-${{ github.run_number }}-failed
if: ${{ failure() }}
summary:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Get exit code from cache
id: get_exit_code
uses: actions/cache@v2
with:
path: failed.txt
key: ${{ env.CI_VERSION }}-${{ github.run_number }}-failed
- name: Set CI Status
if: steps.get_exit_code.outputs.cache-hit == 'true'
run: |
echo "At least a job failed"
exit 1