diff --git a/.github/workflows/generate-readme.yaml b/.github/workflows/generate-readme.yaml new file mode 100644 index 0000000..9598e66 --- /dev/null +++ b/.github/workflows/generate-readme.yaml @@ -0,0 +1,36 @@ +name: Autogenerate README + +on: + pull_request: + paths: + - .utils/generate_readme.py + - .github/workflows/generate-readme.yml + +jobs: + generate-readme: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r .utils/requirements.txt || true + + - name: Generate README + run: python .utils/generate_readme.py + + - name: Check for uncommitted README changes + run: | + git add README.md + git diff --cached --exit-code || { + echo "::error::README.md is out of date or modified manually. Please re-run the generate_readme script and commit the result."; + exit 1; + } diff --git a/.utils/generate_readme.py b/.utils/generate_readme.py index a311641..84d46c3 100644 --- a/.utils/generate_readme.py +++ b/.utils/generate_readme.py @@ -36,7 +36,7 @@ def extract_metadata(readme_path): metadata = yaml.safe_load(match.group(1)) except yaml.YAMLError as e: print("Error parsing YAML metadata in", readme_path, ":", e) - return None + raise e return metadata diff --git a/CONTRIBUTING b/CONTRIBUTING index ce78843..3974c2e 100644 --- a/CONTRIBUTING +++ b/CONTRIBUTING @@ -18,5 +18,4 @@ To contribute a tutorial, please follow these steps: - `blog_post_url` - the url to blog post (optional) - `video_url` - the url to the video (optional) - `visualize_url` - the url to Foxglove visualization (optional) - -When creating a merge request, a GitHub action should automatically regenerate the README based on your metadata. To test it yourself, you can run the python script `.utils/generate_readme.py` in the root of this repo. +4. Regenerate the main README.md by running `python .utils/generate_readme.py` from the root of the repo (install `.utils/requirements.txt` if needed). diff --git a/README.md b/README.md index 13b508a..db31e1d 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ Below is a list of all tutorials available in this repository: ### [Foxglove Visualization for 1X World Model Challenge](datasets/1x_eve/README.md) - 📝 Use Foxglove to visualize 1X World Model Challenge - 🎥 [Video](https://www.youtube.com/watch?v=A9wl491ltPA) -### [Convert .mat files to MCAP](datasets/NASA_mat_to_MCAP/README.md) -- 📝 Visualize Matlab files for NASA Valkyrie box pickup task ### [Converting Argoverse 2 Dataset to MCAP](datasets/foxglove_av2_tutorial/README.md) - 📝 This example converts the LiDAR scans from an AV2 log to MCAP. - 🎥 [Video](https://youtu.be/tBj1LrL1v18) @@ -85,4 +83,4 @@ Below is a list of all tutorials available in this repository: - 📝 Load and analyze data in Jupyter Notebooks using Foxglove Data Management - 🔗 [Related Blog Post](https://foxglove.dev/blog/analyze-your-robotics-data-with-jupyter-notebooks) -Join the Foxglove [Discord](https://discord.gg/UEuytgVkks) and follow [our blog](https://foxglove.dev/blog) for more ideas on how to integrate Foxglove into your robotics development workflows. \ No newline at end of file +Join the Foxglove [Discord](https://discord.gg/UEuytgVkks) and follow [our blog](https://foxglove.dev/blog) for more ideas on how to integrate Foxglove into your robotics development workflows.