composer / composer

Dependency Manager for PHP

Home Page:https://getcomposer.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Archive exclude does not work on GitHub nor Packagist

dakujem opened this issue · comments

I added archive.exclude rules into my composer.json scheme to at least 2 packages, and the archives generated by GitHub (also privately hosted GitLab CE 16.10) still do contain the excluded files, both GitHub Actions config files and test files.
Screenshot 2024-04-24 143515

Consequently, the test files and CI config files end up in the vendors of projects, which is what the archive.exclude is supposed to mitigate.

My composer.json (github link here)

{
  "name": "dakujem/cumulus",
...
  "archive": {
    "exclude": [
      "/tests",
      "/.github"
    ]
  }
}

The generated archive can be found here. As can be seen, both /tests and /.github dirs are present in the archives.

In comparison, my other package does not suffer from this issue, visible here: tag created for purpose of this issue. I assumed the difference was that the exclude had been added prior to creating any tag/release, but this is not the case, as the first alpha release archive does contain the tests, but the later ones do not. This is even more strange, since the first alpha tag points to a commit that excludes the test files. Does this imply some sort of caching issues? If so, how come it affects 4 platforms independetly (GitHub, GitLab, Packagist, privately hosted Satis).

Locally, I observe the rules being effective, as I run composer archive and the excluded directores are absent as I add them to composer.json.

I'm sorry, I have no idea where else to report this issue.

The archive configuration in your composer.json file is only used to create archive files via composer archive. If you want to make sure those folders aren't included in the default ZIP files created by GitHub and GitLab then the recommend way is to exclude them via . gitattributes.

My bad! 🤦‍♂️

Indeed you are correct. It is the missing .gitattributes. Thank you so much for this advice.