diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index 12f6cc5..f848ce6 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -23,7 +23,7 @@ # - name: Copy randomtext.txt into some location in repo # shell: bash -# run: +# run: # name: hello-world # on: push @@ -144,7 +144,7 @@ # # Format XML with indentation # rough_string = ET.tostring(sitemap_index, 'utf-8') # reparsed = minidom.parseString(rough_string) -# pretty_xml = reparsed.toprettyxml(indent=" ") +# pretty_xml = reparsed.toprettyxml(indent=" ") # # Create the tree and write to XML file # with open("globalsitemap.xml", "w") as f: @@ -216,7 +216,7 @@ jobs: - name: Checkout repository main branch uses: actions/checkout@v4 with: - ref: main + ref: main - name: Copy tools folder to /tmp and run sitemap script working-directory: /tmp @@ -249,4 +249,4 @@ jobs: uses: EndBug/add-and-commit@v9 with: default_author: github_actions - message: "update sitemaps folder" \ No newline at end of file + message: "update sitemaps folder" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..716f318 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/psf/black + rev: 24.10.0 + hooks: + - id: black +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.7.3 + hooks: + # Run the linter. + - id: ruff + args: [ --fix ] + # Run the formatter. + - id: ruff-format diff --git a/README.md b/README.md index 016a4e1..173c85c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This repository contains the core web application files and configuration you'll To follow along with the step-by-step instructions in the Essentials module, you will need to create a copy of this repository by doing the following: 1. Click **Use this template** above the file list and select **Create a new repository**. -2. Use the **Owner** dropdown menu to select the account you want to own the repository. +2. Use the **Owner** dropdown menu to select the account you want to own the repository. 3. Name your repository `actions-learning-pathway` and add a simple description to make it easier to identify later. 4. Set the default visibility for the repo to public, as private repositories use Actions minutes, while public repositories can use GitHub-hosted runners for free. diff --git a/SUPPORT.md b/SUPPORT.md index 634a5e7..589ecba 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -1,8 +1,8 @@ -# Support +# Support -This repo contains supplemental content for the [GitHub Actions learning pathway](https://resources.github.com/learn/pathways). +This repo contains supplemental content for the [GitHub Actions learning pathway](https://resources.github.com/learn/pathways). -**actions-learning-pathway** is not an open source project, but rather supplemental demo content maintained by GitHub staff. We encourage users to direct questions to the [Community of Discussions](https://github.com/orgs/community/discussions/) or reference [GitHub Docs](https://docs.github.com/en). +**actions-learning-pathway** is not an open source project, but rather supplemental demo content maintained by GitHub staff. We encourage users to direct questions to the [Community of Discussions](https://github.com/orgs/community/discussions/) or reference [GitHub Docs](https://docs.github.com/en). ## GitHub Support Policy diff --git a/demo-files/build-test-deploy.yml b/demo-files/build-test-deploy.yml index 93932b0..3a7751e 100644 --- a/demo-files/build-test-deploy.yml +++ b/demo-files/build-test-deploy.yml @@ -2,11 +2,11 @@ name: build-test-deploy on: push -jobs: +jobs: build: runs-on: ubuntu-latest - steps: + steps: - name: checkout repo uses: actions/checkout@v3 - name: use node.js @@ -14,14 +14,14 @@ jobs: with: node-version: '18.x' - run: npm install - - run: npm run build + - run: npm run build - test: + test: needs: build runs-on: ubuntu-latest - steps: + steps: - name: checkout repo uses: actions/checkout@v3 - name: use node.js @@ -36,15 +36,15 @@ jobs: permissions: contents: write - pages: write - id-token: write + pages: write + id-token: write environment: name: production url: ${{ steps.deployment.outputs.page_url }} - + runs-on: ubuntu-latest - + steps: - name: checkout repo uses: actions/checkout@v3 @@ -59,10 +59,10 @@ jobs: with: static_site_generator: next - run: npm install - - run: npm run build + - run: npm run build - name: upload artifacts uses: actions/upload-pages-artifact@v1 - with: + with: path: './out' - name: deploy id: deployment diff --git a/demo-files/hello-world.yml b/demo-files/hello-world.yml index 06b8d73..1c61d9d 100644 --- a/demo-files/hello-world.yml +++ b/demo-files/hello-world.yml @@ -2,12 +2,12 @@ name: hello-world on: push -jobs: +jobs: hello-world-job: runs-on: ubuntu-latest - steps: + steps: - name: Check out repository code uses: actions/checkout@v3 - run: echo "$(cat hello_world.txt)" diff --git a/next.config.js b/next.config.js index cb324d3..579c15a 100644 --- a/next.config.js +++ b/next.config.js @@ -5,7 +5,7 @@ const nextConfig = { images: { unoptimized: true, }, - + reactStrictMode: true, } diff --git a/public/next.svg b/public/next.svg index 5174b28..5bb00d4 100644 --- a/public/next.svg +++ b/public/next.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/public/vercel.svg b/public/vercel.svg index d2f8422..1aeda7d 100644 --- a/public/vercel.svg +++ b/public/vercel.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/src/create_file.py b/src/create_file.py index bc1f140..e5887bd 100644 --- a/src/create_file.py +++ b/src/create_file.py @@ -1,5 +1,5 @@ # This is a test script that creates a file which I can then upload as artifact on Github # with open('../output_files/sample_file.txt', mode='w') as w: -with open('sample_file.txt', mode='w') as w: - w.write('My name is Moe\nI just started as an employee at Ansys') +with open("sample_file.txt", mode="w") as w: + w.write("My name is Moe\nI just started as an employee at Ansys") diff --git a/tools/catsitemap.py b/tools/catsitemap.py index 83b1c53..581ee2a 100644 --- a/tools/catsitemap.py +++ b/tools/catsitemap.py @@ -4,6 +4,7 @@ from xml.dom import minidom from links import LINKS + def download_file(url: str, dest_path: Path) -> None: """Given the url of a sitemap file, this function downloads the file into destination path (dest_path) @@ -24,15 +25,16 @@ def download_file(url: str, dest_path: Path) -> None: # Send the request try: response = requests.get(url, stream=True, timeout=30) - except requests.exceptions.Timeout as e: + except requests.exceptions.Timeout: print(f"Timed out while trying to get download the sitemap at this url: {url}") raise requests.exceptions.Timeout # Write the file content to the specified location - with open(dest_path, mode='wb') as file: + with open(dest_path, mode="wb") as file: for chunk in response.iter_content(chunk_size=8192): file.write(chunk) + def extract_urls_and_headers(links_dict: dict) -> tuple: """Processes the dictionary of project metadata, confirms existence of a downloadable sitemap, returns valid lists of project names and sitemap urls in a tuple @@ -51,7 +53,7 @@ def extract_urls_and_headers(links_dict: dict) -> tuple: valid_project_names = [] valid_urls = [] for project_name, url in links_dict.items(): - if url == None: + if url is None: continue updated_url = url.split("docs.pyansys.com")[0] + "docs.pyansys.com/sitemap.xml" if requests.get(url).status_code == 404: @@ -75,8 +77,9 @@ def generate_sitemap_index(project_names: list, dest_path: Path) -> None: """ # Create the root element with namespace - sitemap_index = ET.Element("sitemapindex", xmlns="http://www.sitemaps.org/schemas/sitemap/0.9") - + sitemap_index = ET.Element( + "sitemapindex", xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" + ) # Create sitemap elements for each URL for project in project_names: @@ -88,9 +91,9 @@ def generate_sitemap_index(project_names: list, dest_path: Path) -> None: loc.text = modified_url # Format XML with indentation - rough_string = ET.tostring(sitemap_index, 'utf-8') + rough_string = ET.tostring(sitemap_index, "utf-8") reparsed = minidom.parseString(rough_string) - pretty_xml = reparsed.toprettyxml(indent=" ") + pretty_xml = reparsed.toprettyxml(indent=" ") # Create the tree and write to XML file with open(dest_path, "w") as f: @@ -100,7 +103,7 @@ def generate_sitemap_index(project_names: list, dest_path: Path) -> None: # Run the script if __name__ == "__main__": # Create path - folder_path = Path('.') / 'sitemaps' + folder_path = Path(".") / "sitemaps" folder_path.mkdir() # Get actual valid URLS and corresponding project names @@ -111,5 +114,5 @@ def generate_sitemap_index(project_names: list, dest_path: Path) -> None: generate_sitemap_index(project_names, file_path) for index, url in enumerate(project_urls): - file_path = folder_path / (project_names[index] + '_sitemap.xml') - download_file(url, file_path) \ No newline at end of file + file_path = folder_path / (project_names[index] + "_sitemap.xml") + download_file(url, file_path)