How to Create a Read-Only Test Files in GitHub Codespaces for GitHub Classroom?
GitHub Codespaces, GitHub Classroom

How to Create a Read-Only Test Files in GitHub Codespaces for GitHub Classroom?

I am collaborating with an NGO and a user group to organize a large programming workshop and competition. The competition will involve many junior students, and the first round will require them to complete a set of Python exercises and verify their accuracy using PyTest.

One recurring issue in my classes has been that students are often unfamiliar with the IDE and may accidentally modify or delete some tests. To avoid this problem, it would be best to make the test files read-only, preventing students from editing or deleting them. However, the folder that contains the test needs to remain writable.

Here's a simple trick I've come up with to protect the tests from being modified by students.

My devcontainer.json

In summary, use  "CAP_LINUX_IMMUTABLE" with "postAttachCommand": "find tests -type f -name \"*.py\" -exec sudo chattr +i {} \\;",

Rebuild CodeSpace Problem

The read only tests folder will cause problem and disable it before rebuilding CodeSpace.

Conclusion

All educators who use GitHub Classroom and GitHub Codespaces can benefit from this small trick.

Wong Chun Yin,Cyrus (黃俊彥)

AWS ML Hero + Microsoft Azure AI MVP + Google Developer Experts - GCP & AI/ML(GenAI)

1y

Alfredo Deza my temporally solution and wait for the built-in support!

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics