diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ac6621f..91abb11 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ version: 2 updates: - - package-ecosystem: "" # See documentation for possible values + - package-ecosystem: "pip" # See documentation for possible values directory: "/" # Location of package manifests schedule: interval: "weekly" diff --git a/.github/workflows/docker-image-dev.yml b/.github/workflows/docker-image-dev.yml new file mode 100644 index 0000000..80fa29d --- /dev/null +++ b/.github/workflows/docker-image-dev.yml @@ -0,0 +1,16 @@ +name: Docker Image CI + +on: + push: + branches: ['dev'] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag yspeed:$(date +%s) \ No newline at end of file diff --git a/.github/workflows/docker-image-prod.yml b/.github/workflows/docker-image-prod.yml new file mode 100644 index 0000000..9eb8fdb --- /dev/null +++ b/.github/workflows/docker-image-prod.yml @@ -0,0 +1,18 @@ +name: Docker Image CI + +on: + push: + branches: ['main'] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag yspeed:$(date +%s) \ No newline at end of file diff --git a/.github/workflows/docker-publish-dev.yml b/.github/workflows/docker-publish-dev.yml new file mode 100644 index 0000000..4c61695 --- /dev/null +++ b/.github/workflows/docker-publish-dev.yml @@ -0,0 +1,41 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Publish Docker image + +on: + push: + branches: [ "dev" ] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: my-docker-hub-namespace/my-docker-hub-repository + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: foufoudu34/yspeed:dev \ No newline at end of file diff --git a/.github/workflows/docker-publish-package-dev.yml b/.github/workflows/docker-publish-package-dev.yml new file mode 100644 index 0000000..72f8237 --- /dev/null +++ b/.github/workflows/docker-publish-package-dev.yml @@ -0,0 +1,34 @@ +name: Créer et publier une image Docker + +on: + push: + branches: ['dev'] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: foufou-exe/yspeed + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev \ No newline at end of file diff --git a/.github/workflows/docker-publish-package-prod.yml b/.github/workflows/docker-publish-package-prod.yml new file mode 100644 index 0000000..efcb51a --- /dev/null +++ b/.github/workflows/docker-publish-package-prod.yml @@ -0,0 +1,36 @@ +name: Créer et publier une image Docker + +on: + push: + branches: ['main'] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] +env: + REGISTRY: ghcr.io + IMAGE_NAME: foufou-exe/yspeed + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main \ No newline at end of file diff --git a/.github/workflows/docker-publish-prod.yml b/.github/workflows/docker-publish-prod.yml new file mode 100644 index 0000000..c525fd8 --- /dev/null +++ b/.github/workflows/docker-publish-prod.yml @@ -0,0 +1,34 @@ +name: Publish Docker image + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: my-docker-hub-namespace/my-docker-hub-repository + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: foufoudu34/yspeed:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..be71971 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM ubuntu:latest +MAINTAINER foufou-exe + +# Install dependencies +RUN apt-get update -y + +# Install Python +RUN apt-get install -y git curl python3-pip python3-dev build-essential + +RUN cd / + +# Clone the repository +RUN git clone https://github.com/Foufou-exe/Yspeed.git + +WORKDIR /Yspeed + +# Install the requirements +RUN pip3 install -r /Yspeed/requirements.txt + +# Expose the port +EXPOSE 22 + +# Run the app +CMD ["python3", "/Yspeed/Yspeed.py"] + diff --git a/README.md b/README.md index a70dcdd..74223c2 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ YSpeed depends on the following libraries: Make sure you also have a Selenium-compatible driver installed for your preferred browser (Chrome, Firefox, etc.). -## Use screen +## Use CLI
diff --git a/yspeed.py b/yspeed.py index 488353f..9ff369d 100644 --- a/yspeed.py +++ b/yspeed.py @@ -1,7 +1,6 @@ """Docstring for module Yspeed. """ - import os import platform import sys @@ -155,6 +154,7 @@ def _extracted_from_get_speedtest(self) -> object: try: rgpd = result.find_element(By.ID, "onetrust-accept-btn-handler") + rgpd.click() return result except NoSuchElementException: @@ -219,6 +219,9 @@ def define_brower(self) -> object: Initialize and return an instance of Selenium webdriver based on the browser specified in argument. """ system = platform.system().lower() + + + if system == "windows": browser_executables = { "chrome": "chrome.exe", @@ -341,6 +344,11 @@ def gather_network_info(speedtest: Yspeed, progress: Progress) -> dict: **best, **speed, } + + + +def print_network_info(console: Console, info: dict) -> None: + """ This function (print_network_info) prints the network information """ clear_screen() @@ -405,6 +413,8 @@ def _version() -> str: return "0.1.4" + + def author() -> None: """ Prints the name of the script author and their contact information. @@ -417,6 +427,8 @@ def author() -> None: console.print(f"Version Yspeed: {_version()}", style="grey35", justify="center") + + def clear_screen() -> None: """ Clears the terminal screen based on the operating system.