Skip to content

Commit e6c4662

Browse files
authored
Bye CircleCI (#15)
* Bye CircleCI * Remove key * remove 3.7 because of walrus operator * This is why nobody lets me code anymore * Buuuuump
1 parent 56c88ea commit e6c4662

4 files changed

Lines changed: 112 additions & 77 deletions

File tree

.circleci/config.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Python library
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
env:
10+
COVER_PACKAGE: machine
11+
CACHE_VER: 1
12+
13+
jobs:
14+
build:
15+
strategy:
16+
matrix:
17+
python: ["3.8", "3.9"]
18+
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Venv cache
24+
uses: actions/cache@v2
25+
id: venv-cache
26+
with:
27+
path: "venv"
28+
key: venv-${{ matrix.python }}-${{ env.CACHE_VER }}-${{ hashFiles('requirements.txt', 'setup.py') }}
29+
- name: Wheel cache
30+
uses: actions/cache@v2
31+
id: wheel-cache
32+
with:
33+
path: "wheel"
34+
key: wheels-${{ matrix.python }}-${{ env.CACHE_VER }}-${{ hashFiles('requirements.txt', 'setup.py') }}
35+
36+
- name: Set up Python
37+
uses: actions/setup-python@v2
38+
with:
39+
python-version: ${{ matrix.python }}
40+
41+
- name: Set up build environment
42+
if: steps.venv-cache.outputs.cache-hit != 'true'
43+
run: |
44+
sudo apt-get update && sudo apt-get install -y \
45+
build-essential \
46+
linux-headers-generic \
47+
python3-dev \
48+
libssl-dev \
49+
curl \
50+
git \
51+
openssh-client
52+
pip install virtualenv ply setuptools wheel tox codecov
53+
virtualenv ./venv
54+
source ./venv/bin/activate
55+
pip install -U pip
56+
pip install -r requirements.txt
57+
pip install -r requirements-dev.txt
58+
- name: Build wheels
59+
if: steps.wheel-cache.outputs.cache-hit != 'true'
60+
run: |
61+
source ./venv/bin/activate
62+
mkdir -p ./wheel
63+
pip wheel -f ./wheel -w ./wheel -r ./requirements.txt
64+
65+
- name: Build dists
66+
run: |
67+
source ./venv/bin/activate
68+
mkdir -p ./dist
69+
python ./setup.py build bdist_wheel -d ./dist
70+
71+
- name: Upload dists
72+
uses: actions/upload-artifact@v2
73+
with:
74+
name: dist-${{ matrix.python }}
75+
path: dist
76+
77+
test:
78+
strategy:
79+
matrix:
80+
python: ["3.8", "3.9"]
81+
82+
needs: build
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v2
86+
87+
- name: Set up Python
88+
uses: actions/setup-python@v2
89+
with:
90+
python-version: ${{ matrix.python }}
91+
92+
- name: Venv cache
93+
uses: actions/cache@v2
94+
id: venv-cache
95+
with:
96+
path: "venv"
97+
key: venv-${{ matrix.python }}-${{ env.CACHE_VER }}-${{ hashFiles('requirements.txt', 'setup.py') }}
98+
99+
- name: Test with pytest
100+
run: |
101+
source ./venv/bin/activate
102+
mkdir ./reports
103+
pytest --cov=${{ env.COVER_PACKAGE }} --cov-report=term-missing --cov-report=html:./reports/coverage/ --junitxml=./reports/junit.xml ./tests
104+
105+
- name: Upload test reports
106+
uses: actions/upload-artifact@v2
107+
with:
108+
name: test-reports-${{ matrix.python }}
109+
path: ./reports

machine/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
__description__ = "A sexy, simple, yet powerful and extendable Slack bot"
1515
__uri__ = "https://github.com/DandyDev/slack-machine"
1616

17-
__version_info__ = (0, 21, 3)
17+
__version_info__ = (0, 21, 4)
1818
__version__ = ".".join(map(str, __version_info__))
1919

2020
__author__ = "Daan Debie"

machine/slack.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,8 @@ async def get_users(self) -> SlackResponse:
7777

7878
@alru_cache(maxsize=32)
7979
async def find_user_by_id(self, user_id: str) -> Optional[dict]:
80-
for user in (await self.get_users())["members"]:
81-
if user["id"] == user_id:
82-
return user
83-
84-
return None
80+
user_response = await Slack.get_instance().web.users_info(user=user_id)
81+
return user_response.get("user")
8582

8683
def fmt_mention(self, user: dict) -> str:
8784
return f"<@{user['id']}>"

0 commit comments

Comments
 (0)