First, which return do you file?
Foreign nationals become U.S. tax residents through a green card or the substantial presence test: at least 31 days in the U.S. this year and 183 days over three years, counting all days this year, one-third of last year's and one-sixth of the year before. There are exceptions, including the closer connection exception (Form 8840) and treaty tie-breaker rules (Form 8833). In the year you arrive or leave, you may file as dual-status.