FPtje / vscode-semaphore-ci

Unofficial VS Code extension for interacting with Semaphore CI
https://marketplace.visualstudio.com/items?itemName=FPtje.semaphoreci
Creative Commons Zero v1.0 Universal
5 stars 0 forks source link

No branches shown #10

Closed wulffeld closed 1 year ago

wulffeld commented 1 year ago

I'm wondering if this works with private repositories? In the developer tools in VS Code I see a lot 404 requests the semaphore api.

I've set the API key and the organizations field correctly.

FPtje commented 1 year ago

I use this extension for both public and private repositories, more for private than public ones. It does work for me. Does the provided API key have access to these semaphore projects specifically?

One thing you could try is using semaphore's sem tool to see if you can reach things with your api key. IIRC With the -v flag you can see the http requests it makes. You can compare those against the extension http calls.

wulffeld commented 1 year ago

Ah I think I might be on to something. sem cmd works fine.

I think the extension is using the wrong organization name:

This 404s and is what the extension calls:

**advokurser**.semaphoreci.com/api/v1alpha/pipelines...

This works:

**blueprintlearning**.semaphoreci.com/api/v1alpha/pipelines...

advokurser is a name we use in places (like github) for historical reasons but on semaphore we use 'blueprintlearning'. So I don't know if the extension assumes the org name is the same in both places?

FPtje commented 1 year ago

Hmm, yes. The assumption is that those would indeed be the same. That's how the extension guesses which open directory matches which semaphore organisation.

I wonder, if the github organisation cannot be used for this, then what can? Preferably the extension does not query semaphore to see if your repo is in any of the organisations that you configured.

Would it be an idea to configure some sort of mapping? E.g. A workspace config selected organisation, or a map between github org I'd and semaphore org id?

wulffeld commented 1 year ago

I can't really tell 😅 but it seems in my case I definitely need another setting. I would wager that it's probably not uncommon, especially in larger firms, that the github name could be different from the Semaphore org name.

FPtje commented 1 year ago

Hmm, good point. Does the sem tool figure out what the semaphore url is on its own when you run it from the repo, or do you need to explicitly pass blueprintlearning? If it figures it out on its own I could take a peek in its source code to see what it is doing.

wulffeld commented 1 year ago

Well the sem cmd reads from .sem.yaml where the info is stored. If that file is not there then it requires you to run:

sem connect [HOST] [TOKEN]
FPtje commented 1 year ago

Ah, I see. So in sem you can always only have it connect to one semaphore organisation. It simply assumes that you don't work with multiple semaphore organisations, and if you do, you have to run sem connect [HOST] [TOKEN] every time you want to switch.

I remember that I decided to make the organisations config option in this extension a list, because for my personal case I already have to break the above assumption. After all, I work with Semaphore CI projects from more than one organisation.

I see that the sem tool does try to match your git repository with the projects of the organisation. This happens through this endpoint:

GET https://[ORGANISATION_NAME].semaphoreci.com/api/v1alpha/projects

This returns a json list of projects that includes a GitHub URL. So that's something I can use to make the link between organisation and GitHub repository. That way it wouldn't require extra configuration :thinking:

FPtje commented 1 year ago

This should now be fixed in version 0.5.1. Thanks for reporting!

wulffeld commented 1 year ago

Can confirm it works like a charm. Thanks for fixing :)